spring 配置

2023-10-26

不配置 启动事务 会报错(404)
//启用事务管理
@EnableTransactionManagement
@SpringBootApplication(scanBasePackages = { “w.sh." })
@EnableJpaRepositories( basePackages = "w.sh.
.dao”)
@EntityScan(basePackages = “w.sh.*.entity”, basePackageClasses = { ErpApplication.class, Jsr310JpaConverters.class })

//指定jsp页面模板配置
server.port=8010

spring.thymeleaf.prefix=classpath:/templates/
spring.thymeleaf.suffix=.html
spring.thymeleaf.mode=HTML
spring.thymeleaf.encoding=UTF-8
spring.thymeleaf.servlet.content-type=text/html
spring.thymeleaf.cache=false
spring.resources.chain.strategy.content.enabled=true
spring.resources.chain.strategy.content.paths=/**

//数据库配置
spring.datasource.driver-class-name=org.mariadb.jdbc.Driver
spring.datasource.url=jdbc:mariadb://127.0.0.1:3306/erp?useSSL=false&useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC
spring.datasource.username=erp
spring.datasource.password=erp

//数据库连接词
#Spring Boot 2.0 includes HikariDataSource by default
spring.datasource.type = com.zaxxer.hikari.HikariDataSource

spring.datasource.hikari.connection-timeout=20000
spring.datasource.hikari.minimum-idle=5
spring.datasource.hikari.maximum-pool-size=12
spring.datasource.hikari.idle-timeout=300000
spring.datasource.hikari.max-lifetime=1200000
spring.datasource.hikari.auto-commit=true
//hibernate.format_sql=true
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MariaDBDialect
spring.jpa.properties.hibernate.id.new_generator_mappings=false
spring.jpa.properties.hibernate.enable_lazy_load_no_trans=true
spring.jpa.properties.hibernate.format_sql=true
spring.jpa.hibernate.ddl-auto=update
spring.jpa.open-in-view=false

//编码配置
#Charset of HTTP requests and responses. Added to the “Content-Type” header if not set explicitly.
spring.http.encoding.charset=UTF-8
Enable http encoding support.
spring.http.encoding.enabled=true
Force the encoding to the configured charset on HTTP requests and responses.
spring.http.encoding.force=true
//指定路径
logging.config=classpath:logback.xml

org.springframework.boot spring-boot-devtools runtime true 热启动

@controller控制器 表示容器 sspring 容器 是用来管理 java实力的容器 负责将一个java类 实例化 然后在可以将这个实力销毁
spring容器也是一个java类 spring根据包扫描找到类 hellocontrol ,并实例化–这个过程叫控制反转
什么叫控制反转------以前需要手动实例化new一个 现在spring根据包扫描找到类自动实例化
spring不能直接访问视图 service jsp可以 , spring需要请求访问控制器,由控制器将视图转发出来给浏览器

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

spring 配置 的相关文章

随机推荐