运行Maven Liquibase-Hibernate diff会导致PrimaryKey.addColumnName上出现NoSuchMethodError

时间:2014-12-04 16:16:12

标签: hibernate maven liquibase

我正在尝试使用liquibase-hibernate扩展来通过maven在我的hibernate模型和MySQL数据库之间运行差异。我已经配置了liquibase maven插件来从属性文件中获取其配置。

我一直得到' java.lang.NoSuchMethodError:liquibase.structure.core.PrimaryKey.addColumnName'

请参阅下面我的pom.xml,local.properties文件和控制台输出 - 所有帮助非常感谢。

也许是liquibase-core或liquibase maven插件中的错误?

由于

MCAI

local.properties:

driver=com.mysql.jdbc.Driver
url=jdbc:mysql://localhost:3306/zzzzzzzz?createDatabaseIfNotExist=true
username=root
password=
hibernate.dialect=org.hibernate.dialect.MySQLDialect
changeLogFile=changeLogFile.xml
referenceUrl=hibernate:spring:com.zzzzzzzz.repository.model?dialect=org.hibernate.dialect.MySQL5Dialect

的pom.xml:

<build>
    <plugins>
        <plugin>
            <groupId>org.liquibase</groupId>
            <artifactId>liquibase-maven-plugin</artifactId>
            <version>3.3.0</version>
            <configuration>
                <!-- Liquibase will read the properties file for its config -->
                <propertyFile>src/main/resources/local.properties</propertyFile>
                <changeLogFile>liquibase.xml</changeLogFile>
            </configuration>
            <dependencies>
                <!-- Liquibase Hibernate Extention Depends on Core -->
                <dependency>
                    <groupId>org.liquibase.ext</groupId>
                    <artifactId>liquibase-hibernate4</artifactId>
                    <version>3.4</version>
                </dependency>
                <dependency>
                    <groupId>org.liquibase</groupId>
                    <artifactId>liquibase-core</artifactId>
                    <version>3.3.0</version>
                </dependency>
                <!-- Spring as using Hibernate Reference URL for diff -->
                <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-context</artifactId>
                    <version>${spring.version}</version>
                </dependency>
                <dependency>
                    <groupId>org.springframework</groupId>
                    <artifactId>spring-orm</artifactId>
                    <version>${spring.version}</version>
                </dependency>
            </dependencies>.
            <!-- -->
        </plugin>
    </plugins>
</build>

maven命令的控制台输出:

mvn liquibase:diff         
[INFO] Scanning for projects...
[INFO]                                                                         
[INFO] ------------------------------------------------------------------------
[INFO] Building repository 0.0.1-SNAPSHOT
[INFO] ------------------------------------------------------------------------
[INFO] 
[INFO] --- liquibase-maven-plugin:3.3.0:diff (default-cli) @ repository ---
[INFO] ------------------------------------------------------------------------
[INFO] Parsing Liquibase Properties File
[INFO]   File: src/main/resources/local.properties
[INFO]   'hibernate.dialect' in properties file is not being used by this task.
[INFO] ------------------------------------------------------------------------
[INFO] Executing on Database: jdbc:mysql://localhost:3306/zzzzzzzz?createDatabaseIfNotExist=true
INFO 04/12/14 16:01: liquibase-hibernate: Reading hibernate configuration hibernate:spring:com.zzzzzzzz.repository.model?dialect=org.hibernate.dialect.MySQL5Dialect
INFO 04/12/14 16:01: liquibase-hibernate: Found package com.zzzzzzzz.repository.model
INFO 04/12/14 16:01: liquibase-hibernate: Found dialect org.hibernate.dialect.MySQL5Dialect
INFO 04/12/14 16:01: liquibase-hibernate: Found hibernate.enhanced_idfalse
Dec 04, 2014 4:01:17 PM org.hibernate.jpa.internal.util.LogHelper logPersistenceUnitInformation
INFO: HHH000204: Processing PersistenceUnitInfo [
    name: default
    ...]
Dec 04, 2014 4:01:17 PM org.hibernate.Version logVersion
INFO: HHH000412: Hibernate Core {4.3.1.Final}
Dec 04, 2014 4:01:17 PM org.hibernate.cfg.Environment <clinit>
INFO: HHH000206: hibernate.properties not found
Dec 04, 2014 4:01:17 PM org.hibernate.cfg.Environment buildBytecodeProvider
INFO: HHH000021: Bytecode provider name : javassist
Dec 04, 2014 4:01:17 PM org.hibernate.annotations.common.reflection.java.JavaReflectionManager <clinit>
INFO: HCANN000001: Hibernate Commons Annotations {4.0.4.Final}
Dec 04, 2014 4:01:17 PM org.hibernate.dialect.Dialect <init>
INFO: HHH000400: Using dialect: org.hibernate.dialect.MySQL5Dialect
INFO 04/12/14 16:01: liquibase-hibernate: Using dialect org.hibernate.dialect.MySQL5Dialect
[INFO] Performing Diff on database root@localhost @ jdbc:mysql://localhost:3306/zzzzzzzz?createDatabaseIfNotExist=true (Default Schema: zzzzzzzz)

Diff Results:
INFO 04/12/14 16:01: liquibase-hibernate: Found table Product
INFO 04/12/14 16:01: liquibase-hibernate: Found table Product
INFO 04/12/14 16:01: liquibase-hibernate: Found column id integer
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.528s
[INFO] Finished at: Thu Dec 04 16:01:17 GMT 2014
[INFO] Final Memory: 18M/225M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.liquibase:liquibase-maven-plugin:3.3.0:diff (default-cli) on project repository: Execution default-cli of goal org.liquibase:liquibase-maven-plugin:3.3.0:diff failed: An API incompatibility was encountered while executing org.liquibase:liquibase-maven-plugin:3.3.0:diff: java.lang.NoSuchMethodError: liquibase.structure.core.PrimaryKey.addColumnName(ILjava/lang/String;)Lliquibase/structure/core/PrimaryKey;
[ERROR] -----------------------------------------------------
[ERROR] realm =    plugin>org.liquibase:liquibase-maven-plugin:3.3.0
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy
[ERROR] urls[0] = file:/Users/User/.m2/repository/org/liquibase/liquibase-maven-plugin/3.3.0/liquibase-maven-plugin-3.3.0.jar
[ERROR] urls[1] = file:/Users/User/.m2/repository/org/liquibase/ext/liquibase-hibernate4/3.4/liquibase-hibernate4-3.4.jar
[ERROR] urls[2] = file:/Users/User/.m2/repository/org/hibernate/hibernate-core/4.3.1.Final/hibernate-core-4.3.1.Final.jar
[ERROR] urls[3] = file:/Users/User/.m2/repository/org/jboss/logging/jboss-logging/3.1.3.GA/jboss-logging-3.1.3.GA.jar
[ERROR] urls[4] = file:/Users/User/.m2/repository/org/jboss/logging/jboss-logging-annotations/1.2.0.Beta1/jboss-logging-annotations-1.2.0.Beta1.jar
[ERROR] urls[5] = file:/Users/User/.m2/repository/org/jboss/spec/javax/transaction/jboss-transaction-api_1.2_spec/1.0.0.Final/jboss-transaction-api_1.2_spec-1.0.0.Final.jar
[ERROR] urls[6] = file:/Users/User/.m2/repository/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar
[ERROR] urls[7] = file:/Users/User/.m2/repository/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar
[ERROR] urls[8] = file:/Users/User/.m2/repository/org/hibernate/common/hibernate-commons-annotations/4.0.4.Final/hibernate-commons-annotations-4.0.4.Final.jar
[ERROR] urls[9] = file:/Users/User/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.1-api/1.0.0.Final/hibernate-jpa-2.1-api-1.0.0.Final.jar
[ERROR] urls[10] = file:/Users/User/.m2/repository/org/javassist/javassist/3.18.1-GA/javassist-3.18.1-GA.jar
[ERROR] urls[11] = file:/Users/User/.m2/repository/antlr/antlr/2.7.7/antlr-2.7.7.jar
[ERROR] urls[12] = file:/Users/User/.m2/repository/org/jboss/jandex/1.1.0.Final/jandex-1.1.0.Final.jar
[ERROR] urls[13] = file:/Users/User/.m2/repository/org/hibernate/javax/persistence/hibernate-jpa-2.0-api/1.0.1.Final/hibernate-jpa-2.0-api-1.0.1.Final.jar
[ERROR] urls[14] = file:/Users/User/.m2/repository/org/hibernate/hibernate-entitymanager/4.3.1.Final/hibernate-entitymanager-4.3.1.Final.jar
[ERROR] urls[15] = file:/Users/User/.m2/repository/org/hibernate/hibernate-envers/4.3.1.Final/hibernate-envers-4.3.1.Final.jar
[ERROR] urls[16] = file:/Users/User/.m2/repository/org/liquibase/liquibase-core/3.3.0/liquibase-core-3.3.0.jar
[ERROR] urls[17] = file:/Users/User/.m2/repository/org/yaml/snakeyaml/1.13/snakeyaml-1.13.jar
[ERROR] urls[18] = file:/Users/User/.m2/repository/org/springframework/spring-context/4.0.2.RELEASE/spring-context-4.0.2.RELEASE.jar
[ERROR] urls[19] = file:/Users/User/.m2/repository/org/springframework/spring-aop/4.0.2.RELEASE/spring-aop-4.0.2.RELEASE.jar
[ERROR] urls[20] = file:/Users/User/.m2/repository/aopalliance/aopalliance/1.0/aopalliance-1.0.jar
[ERROR] urls[21] = file:/Users/User/.m2/repository/org/springframework/spring-beans/4.0.2.RELEASE/spring-beans-4.0.2.RELEASE.jar
[ERROR] urls[22] = file:/Users/User/.m2/repository/org/springframework/spring-core/4.0.2.RELEASE/spring-core-4.0.2.RELEASE.jar
[ERROR] urls[23] = file:/Users/User/.m2/repository/commons-logging/commons-logging/1.1.3/commons-logging-1.1.3.jar
[ERROR] urls[24] = file:/Users/User/.m2/repository/org/springframework/spring-expression/4.0.2.RELEASE/spring-expression-4.0.2.RELEASE.jar
[ERROR] urls[25] = file:/Users/User/.m2/repository/org/springframework/spring-orm/4.0.2.RELEASE/spring-orm-4.0.2.RELEASE.jar
[ERROR] urls[26] = file:/Users/User/.m2/repository/org/springframework/spring-jdbc/4.0.2.RELEASE/spring-jdbc-4.0.2.RELEASE.jar
[ERROR] urls[27] = file:/Users/User/.m2/repository/org/springframework/spring-tx/4.0.2.RELEASE/spring-tx-4.0.2.RELEASE.jar
[ERROR] urls[28] = file:/Users/User/.m2/repository/org/codehaus/plexus/plexus-utils/1.0.4/plexus-utils-1.0.4.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import  from realm ClassRealm[maven.api, parent: null]]
[ERROR] 
[ERROR] -----------------------------------------------------
[ERROR] -> [Help 1]
[ERROR] 
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR] 
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginContainerException

1 个答案:

答案 0 :(得分:3)

Liquibase 3.3.0和Liquibase-Hibernate 3.4之间存在API兼容性问题。 Liquibase-hibernate 3.5和Liquibase 3.3.1解决了不兼容问题,应该很快就会发布。