Spring Boot 2.2.1 H2失败?

我有一个使用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发生了变化,但这只是一个猜测,因为我遇到了麻烦在问题/变更日志中找到明显的原因。

fankaoquan 回答:Spring Boot 2.2.1 H2失败?

除非启用了MySQL兼容模式,否则不能在H2 1.4.200中使用ENGINE=InnoDB子句。

如果要启用它,请将;MODE=MySQL附加到连接URL。您可能还想添加;DATABASE_TO_LOWER=TRUE并可能添加;CASE_INSENSITIVE_IDENTIFIERS=TRUE。对于MySQL兼容模式,不会自动启用这些标志。

本文链接:https://www.f2er.com/3116364.html

大家都在问