设置mysql 引擎为innodb:
复制代码
1spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
自动创建表时,多了一张表hibernate_sequence
这里要指定主键自增策略,默认是以Oracle的方式来实现自增主键。想用mysql的自增方式需要改为
复制代码
1@GeneratedValue(strategy = GenerationType.IDENTITY)
数据库连接配置:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24spring.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内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复