【问题标题】:Error during testing for MySQL/MariaDB JDBC driver bug测试 MySQL/MariaDB JDBC 驱动程序错误时出错
【发布时间】:2019-06-07 05:19:54
【问题描述】:

我一直在尝试将 Liquibase 3.6.3 与 spring boot 2.1.5.RELEASE 应用程序集成,但在运行应用程序时出现此错误。

Caused by: liquibase.exception.DatabaseException: liquibase.exception.UnexpectedLiquibaseException: Error during testing for MySQL/MariaDB JDBC driver bug: could not retrieve JDBC metadata information for temporary table 'TMP_TYIVMBAICPSUJGIJ'
at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:223) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:66) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.jvm.JdbcSnapshotGenerator.snapshot(JdbcSnapshotGenerator.java:69) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.SnapshotGeneratorChain.snapshot(SnapshotGeneratorChain.java:49) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:286) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:407) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:334) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:309) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:407) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:429) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:334) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:309) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.replaceObject(DatabaseSnapshot.java:386) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.includeNestedObjects(DatabaseSnapshot.java:334) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.include(DatabaseSnapshot.java:309) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.init(DatabaseSnapshot.java:102) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.DatabaseSnapshot.<init>(DatabaseSnapshot.java:59) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.JdbcDatabaseSnapshot.<init>(JdbcDatabaseSnapshot.java:38) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:217) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:246) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.SnapshotGeneratorFactory.createSnapshot(SnapshotGeneratorFactory.java:230) ~[liquibase-core-3.6.3.jar:na]
at liquibase.change.core.LoadDataChange.retrieveMissingColumnLoadTypes(LoadDataChange.java:581) ~[liquibase-core-3.6.3.jar:na]
at liquibase.change.core.LoadDataChange.generateStatements(LoadDataChange.java:283) ~[liquibase-core-3.6.3.jar:na]
... 121 common frames omitted

Caused by: liquibase.exception.UnexpectedLiquibaseException: Error during testing for MySQL/MariaDB JDBC driver bug: could not retrieve JDBC metadata information for temporary table 'TMP_TYIVMBAICPSUJGIJ'
at liquibase.database.core.MySQLDatabase.hasBugJdbcConstraintsDeferrable(MySQLDatabase.java:275) ~[liquibase-core-3.6.3.jar:na]
at liquibase.snapshot.jvm.ForeignKeySnapshotGenerator.snapshotObject(ForeignKeySnapshotGenerator.java:188) ~[liquibase-core-3.6.3.jar:na]
... 144 common frames omitted

我的配置如下;

    outputChangeLogFile=src/main/resources/config/db/db.changelog-master.xml
    driver = com.mysql.cj.jdbc.Driver
    url=jdbc:mysql://localhost:3306/<dbname>?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&useTimezone=true&serverTimezone=UTC
    username = <username>
    password = <password>

同时添加主更改日志文件

 <?xml version="1.1" encoding="UTF-8" standalone="no"?>
 <databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">

<include file="classpath:config/db/changelog/db.changelog-1.0.xml" relativeToChangelogFile="false"/>
<include file="classpath:config/db/changelog/db.changelog-1.1.xml" relativeToChangelogFile="false"/>

我尝试将版本更改为 3.5.3,然后 spring 给出了错误

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:
org.springframework.boot.autoconfigure.liquibase.LiquibaseAutoConfiguration$LiquibaseConfiguration.liquibase(LiquibaseAutoConfiguration.java:127)

The following method did not exist:

liquibase.integration.spring.SpringLiquibase.setLiquibaseSchema(Ljava/lang/String;)V

The method's class, liquibase.integration.spring.SpringLiquibase, is available from the following locations:

jar:file:/C:/Users/<user>/.m2/repository/org/liquibase/liquibase-core/3.5.3/liquibase-core-3.5.3.jar!/liquibase/integration/spring/SpringLiquibase.class

It was loaded from the following location:

file:/C:/Users/<user>/.m2/repository/org/liquibase/liquibase-core/3.5.3/liquibase-core-3.5.3.jar


 Action:

 Correct the classpath of your application so that it contains a single, compatible version of liquibase.integration.spring.SpringLiquibase

这是一个错误吗?我该如何解决这个问题?

注意: liquibase-maven-plugin:3.5.3:update using

mvn: liquibase:update

帮助我生成表格。我用过

liquibase-maven-plugin:3.5.3

用于生成它。 还是不知道为什么3.6.3报错。

【问题讨论】:

    标签: java xml spring spring-boot liquibase


    【解决方案1】:

    问题可能是您的 MySQL 实例以 MyISAM 作为默认存储引擎运行。

    在 3.6.x 和 3.7.x 版本中,Liquibase 尝试创建一个临时表来检查 jdbc 驱动程序错误。如果它是使用 MyISAM 引擎创建的,则该表的约束是可延迟的。 Liquibase 将此转换为“驱动程序错误”错误(他们的方法甚至被命名为 hasBugJdbcConstraintsDeferrable)。

    解决问题:

  • 将 InnoDb 设置为默认存储引擎以避免该问题
  • 或将 liquibase 降级到 3.5.x
  • 或将 Liquibase 升级到未来的 4.0.x(尚未发布)。
  • 【讨论】:

    • 已经降级到 liquibase-maven-plugin:3.5.3。并找到了替代解决方案。感谢您的回复。
    • 我遇到了同样的错误,我默认使用 InnoDb 并降级到 liquibase 3.5.3..
    • @SebinThomas,我也面临同样的问题,在找到这个确切的问题之前,我经历了这个问题中提到的所有方法。您能否分享替代解决方案或解决此问题的一些提示?
    • @m.arsrabon 我在 Spring boot 中使用了 Liquibase,由于我使用的是 Liquibase 版本,我遇到了这样的错误。我想在运行应用程序时对数据库进行更改,但没有发生。因此我使用了 maven 命令 mvn: liquibase:update 来执行操作。
    猜你喜欢
    • 2014-10-24
    • 2014-06-30
    • 2013-03-26
    • 1970-01-01
    • 2014-03-30
    • 2013-08-27
    • 1970-01-01
    • 2012-09-16
    • 1970-01-01
    相关资源
    最近更新 更多