首页 > 解决方案 > Spring Boot - MySQL 默认使用 InnoDB

问题描述

我想用 InnoDB 创建我的数据库表,我使用的是 Spring Boot 2.1.3 和 MySQL 8.0,所以我使用了这个:

spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL8Dialect

而且,是的,它有效,但我的控制台中有很多错误:

2019-04-03 19:11:55.182  INFO 1820 --- [  restartedMain] org.hibernate.dialect.Dialect            : HHH000400: Using dialect: org.hibernate.dialect.MySQL8Dialect
2019-04-03 19:11:55.966  WARN 1820 --- [  restartedMain] o.h.t.s.i.ExceptionHandlerLoggedImpl     : GenerationTarget encountered exception accepting command : Error executing DDL "alter table application drop foreign key FKldca8xj6lqb3rsqawrowmkqbg" via JDBC Statement

org.hibernate.tool.schema.spi.CommandAcceptanceException: Error executing DDL "alter table application drop foreign key FKldca8xj6lqb3rsqawrowmkqbg" via JDBC Statement

我的每张桌子都有这个:

Caused by: java.sql.SQLSyntaxErrorException: Table 'test.usr' doesn't exist

“test.usr” -> “test” 是我的模式名称,“usr” 是表名。

但它仍然会创建我所有的表,所以我怎样才能摆脱这个错误?

标签: mysqlhibernatespring-bootdialect

解决方案


正如 Antoniossss 所提议的,我刚刚使用 Flyway 来处理我的数据库。谢谢。


推荐阅读