Spring 引导 2.2.1 H2 失败?
Spring Boot 2.2.1 H2 Failures?
我有一个使用 Spring Boot 2.2.0、H2 和 Flyway 的项目,运行良好。 Spring Boot 2.2.1 刚刚发布(所以我得到了 Dependabot PR),现在我的迁移像这样失败了(paths/table names/columns sanitized):
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[=11=](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 提示问题所在的引导。
我猜这要么与 Spring 引导将 H2 自动配置为测试数据库有关(也许是兼容模式?),要么只是对 H2 的更改,但这只是一个猜测,因为我无法在 issues/changelog.
中找到明显的原因
除非启用 MySQL 兼容模式,否则不能在 H2 1.4.200 中使用 ENGINE=InnoDB
子句。
如果要启用它,请将 ;MODE=MySQL
附加到连接 URL。您可能还想添加 ;DATABASE_TO_LOWER=TRUE
和可能的 ;CASE_INSENSITIVE_IDENTIFIERS=TRUE
。 MySQL 兼容模式不会自动启用这些标志。
我有一个使用 Spring Boot 2.2.0、H2 和 Flyway 的项目,运行良好。 Spring Boot 2.2.1 刚刚发布(所以我得到了 Dependabot PR),现在我的迁移像这样失败了(paths/table names/columns sanitized):
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[=11=](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 提示问题所在的引导。
我猜这要么与 Spring 引导将 H2 自动配置为测试数据库有关(也许是兼容模式?),要么只是对 H2 的更改,但这只是一个猜测,因为我无法在 issues/changelog.
中找到明显的原因除非启用 MySQL 兼容模式,否则不能在 H2 1.4.200 中使用 ENGINE=InnoDB
子句。
如果要启用它,请将 ;MODE=MySQL
附加到连接 URL。您可能还想添加 ;DATABASE_TO_LOWER=TRUE
和可能的 ;CASE_INSENSITIVE_IDENTIFIERS=TRUE
。 MySQL 兼容模式不会自动启用这些标志。