网站/小程序/APP个性化定制开发,二开,改版等服务,加扣:8582-36016

1.application.properties配置jpa模板

spring.datasource.url=jdbc:mysql://localhost:3306/springboottest?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC 
spring.datasource.username=root
spring.datasource.password=Zp970321
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver

#jpa setting
spring.jpa.database-platform=org.hibernate.dialect.MySQL5InnoDBDialect

spring.jpa.hibernate.ddl-auto=update

spring.jpa.show-sql=true

注意:url上一定要加上时区serverTimezone=UTC ,否则会报错。

当使用JPA访问数据库时,一定要设置数据库方言

2.application.properties配置Druid数据源

springboot的默认数据源:org.apache.tomcat.jdbc.pool.DateSource

修改数据源为Druid的配置如下:

spring.datasource.type=com.alibaba.druid.pool.DruidDataSource

常用的数据源属性配置如下:

spring.datasource.initSize=5
spring.datasource.minIdle=5
spring.datasource.maxActive=20
spring.datasource.maxWait=6000
spring.datasource.timeBetweenEvictionRunsMillis=60000
spring.datasource.minEvictableIdleTimeMillis=300000


评论 0

暂无评论
0
0
0
立即
投稿
发表
评论
返回
顶部