Liquibase生成与Springboot 3的差异

fnatzsnv  于 2023-01-13  发布在  Spring
关注(0)|答案(1)|浏览(151)

我尝试用liquibase 4.18.0和Sping Boot 3.0.1生成liquibase脚本。
我得到这个错误:

[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:4.18.0:diff (default-cli) on project ims-backend: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:4.18.0:diff failed: An API incompatibility was encountered while executing org.liquibase:liquibase-maven-plugin:4.18.0:diff: java.lang.NoSuchMethodError: 'javax.persistence.spi.PersistenceUnitInfo org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainDefaultPersistenceUnitInfo()'
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.liquibase:liquibase-maven-plugin:4.18.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/C:/Users/XXXX/.m2/repository/org/liquibase/liquibase-maven-plugin/4.18.0/liquibase-maven-plugin-4.18.0.jar
[ERROR] urls[1] = file:/C:/Users/XXXX/.m2/repository/org/liquibase/liquibase-core/4.18.0/liquibase-core-4.18.0.jar
[ERROR] urls[2] = file:/C:/Users/XXXX/.m2/repository/javax/xml/bind/jaxb-api/2.3.1/jaxb-api-2.3.1.jar
[ERROR] urls[3] = file:/C:/Users/XXXX/.m2/repository/javax/activation/javax.activation-api/1.2.0/javax.activation-api-1.2.0.jar
[ERROR] urls[4] = file:/C:/Users/XXXX/.m2/repository/org/yaml/snakeyaml/1.33/snakeyaml-1.33.jar
[ERROR] urls[5] = file:/C:/Users/XXXX/.m2/repository/com/opencsv/opencsv/5.7.1/opencsv-5.7.1.jar
[ERROR] urls[6] = file:/C:/Users/XXXX/.m2/repository/org/apache/commons/commons-lang3/3.12.0/commons-lang3-3.12.0.jar
[ERROR] urls[7] = file:/C:/Users/XXXX/.m2/repository/org/apache/commons/commons-text/1.10.0/commons-text-1.10.0.jar
[ERROR] urls[8] = file:/C:/Users/XXXX/.m2/repository/org/apache/commons/commons-collections4/4.4/commons-collections4-4.4.jar
[ERROR] urls[9] = file:/C:/Users/XXXX/.m2/repository/org/liquibase/liquibase-commercial/4.18.0/liquibase-commercial-4.18.0.jar
[ERROR] urls[10] = file:/C:/Users/XXXX/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR]

看来

org.springframework.orm.jpa.persistenceunit.DefaultPersistenceUnitManager.obtainDefaultPersistenceUnitInfo()

现在返回

jakarta.persistence.spi.PersistenceUnitInfo

代替

javax.persistence.spi.PersistenceUnitInfo

有什么我可以做的,或者是唯一的选择,等待一个新的liquibase版本?

monwx1rj

monwx1rj1#

好的,我可以修复使用liquibase-hibernate 6而不是liquibase-hibernate 5时的问题

<dependency>
    <groupId>org.liquibase.ext</groupId>
    <artifactId>liquibase-hibernate6</artifactId>
    <version>${liquibase.version}</version>
    <scope>test</scope>
</dependency>

但是我不得不在我的项目中将liquibase.version重写为4.18.0,因为它只适用于4.18,而spring Boot 目前使用的是4.17

<liquibase.version>4.18.0</liquibase.version>

而且我必须改变

hibernate.physical_naming_strategy=org.springframework.boot.orm.jpa.hibernate.SpringPhysicalNamingStrategy

变成

hibernate.physical_naming_strategy=org.hibernate.boot.model.naming.CamelCaseToUnderscoresNamingStrategy

相关问题