Spring Boot 2.2.1 H2失败? [英] Spring Boot 2.2.1 H2 Failures?

查看:213
本文介绍了Spring Boot 2.2.1 H2失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Spring Boot 2.2.0,H2和Flyway正常运行的项目.Spring Boot 2.2.1刚刚发布(因此我获得了Dependabot PR),现在我的迁移失败了(路径/表名/列已清除):

I have a project with Spring Boot 2.2.0, H2 and Flyway that's working fine. Spring Boot 2.2.1 just came out (so I got a Dependabot PR), and now my migrations are failing like this (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$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的问题或变更日志中看到一个明显的问题,该问题表明了问题所在说谎.

Nothing changed except Spring Boot's version (and from the looks of things, that means some transitive dependencies, including H2), but I don't see an obvious issue in the issues or the changelog for Spring Boot that suggests where the problem lies.

我猜想这可能与Spring Boot将H2自动配置为测试数据库有关(也许是兼容模式?),或者只是与H2发生了变化,但这只是一个猜测,因为我遇到了麻烦在问题/变更日志中找到明显的原因.

I'm guessing this either has something to do with Spring Boot's auto configuration of H2 as a test database (maybe the compatibility mode?) or just a change with H2, but it's just a guess, since I'm having trouble finding an obvious cause in the issues/changelog.

推荐答案

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

You cannot use ENGINE=InnoDB clause in H2 1.4.200 unless MySQL compatibility mode is enabled.

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

If you want to enable it, append ;MODE=MySQL to the connection URL. You also may want to add ;DATABASE_TO_LOWER=TRUE and possibly ;CASE_INSENSITIVE_IDENTIFIERS=TRUE. These flags aren't enabled automatically for MySQL compatibility mode.

这篇关于Spring Boot 2.2.1 H2失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆