概述
设置mysql 引擎为innodb:
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
自动创建表时,多了一张表hibernate_sequence
这里要指定主键自增策略,默认是以Oracle的方式来实现自增主键。想用mysql的自增方式需要改为
@GeneratedValue(strategy = GenerationType.IDENTITY)
数据库连接配置:
spring.datasource.username=root
spring.datasource.password=123456
spring.datasource.url=jdbc:mysql://localhost:3306/website?characterEncoding=utf-8&serverTimezone=UTC
#最小连接
spring.datasource.hikari.minimum-idle=5
#最大连接
spring.datasource.hikari.maximum-pool-size=20
#自动提交
spring.datasource.hikari.auto-commit=true
#最大空闲时间
spring.datasource.hikari.idle-timeout=30000
#连接池名
spring.datasource.hikari.pool-name=DatebookHikariCP
#最大生命周期
spring.datasource.hikari.max-lifetime=1800000
#连接超时时间
spring.datasource.hikari.connection-timeout=30000
#心跳检测
spring.datasource.hikari.connection-test-query=SELECT 1
spring.jpa.database = MYSQL
spring.jpa.show-sql = true
spring.jpa.hibernate.ddl-auto = update
spring.jpa.hibernate.naming.physical-strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
最后
以上就是欢呼小蝴蝶为你收集整理的spring boot 2.0.x 使用 hibernate、mysql 的问题的全部内容,希望文章能够帮你解决spring boot 2.0.x 使用 hibernate、mysql 的问题所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复