【发布时间】:2020-03-08 07:53:27
【问题描述】:
我有一个运行良好的 Spring Boot 2.2.0、H2 和 Flyway 项目。 Spring Boot 2.2.1 刚刚发布(所以我得到了一个 Dependabot PR),现在我的迁移失败了(路径/表名/列已清理):
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'flywayInitializer' defined in class path resource [org/springframework/boot/autoconfigure/flyway/FlywayAutoConfiguration$FlywayConfiguration.class]: Invocation of init method failed; nested exception is org.flywaydb.core.internal.command.DbMigrate$FlywayMigrateException:
Migration V1__Creating_tableName_table.sql failed
------------------------------------------------------
SQL State : 42001
Error Code : 42001
Message : Syntax error in SQL statement "CREATE TABLE MY_PROJECT_TABLE (
-- table definition here
) ENGINE=[*]INNODB"; expected "identifier"; SQL statement:
CREATE TABLE my_project_table (
-- table definition here
) ENGINE=InnoDB [42001-200]
Location : db/migration/V1__Creating_tableName_table.sql (/path/to/file.sql)
Line : 1
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1803) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:222) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.1.RELEASE.jar:5.2.1.RELEASE]
看起来它不喜欢 ENGINE=INNODB 部分
除了 Spring Boot 的版本没有任何变化(从外观上看,这意味着一些传递依赖,包括 H2),但我在问题或 Spring Boot 的变更日志中没有看到明显的问题,表明问题出在哪里谎言。
我猜这要么与 Spring Boot 将 H2 自动配置为测试数据库(可能是兼容模式?)有关,要么与 H2 的更改有关,但这只是一个猜测,因为我遇到了麻烦在问题/变更日志中找到明显的原因。
【问题讨论】:
-
表定义中是否有尾随逗号? H2 1.4.200(这是 Boot 2.2.1 中的默认版本)放弃了对它们的支持:github.com/h2database/h2database/pull/2099。
-
是的,我发现了这个问题并查看了,不,我没有看到任何尾随逗号。
标签: spring-boot h2 flyway