刚开始接触springboot时,创建表只能产生索引而不产生外键,最后发现时数据库引擎的问题,mysql默认的引擎是 “InnoDB”,因此在yml配置文件中加入
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
即可,整体事例:
spring:
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://localhost:3306/blogs?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC
username: root
password: 123456
jpa:
hibernate:
ddl-auto: create
show-sql: true
database-platform: org.hibernate.dialect.MySQL5InnoDBDialect
logging:
level:
root: info
com.yys: debug
file: log/blog-dev.log