我已经成功地将 hibernate3-maven-plugin 与 Hibernate-Core 和 EntityManager 3.6.6-FINAL、hibernate-commons-annotations-3.2.0.Final、hibernate-jpa-2.0-api-1.0.1.Final 和 hibernate-validator 一起使用-4.0.0.GA 最近。我正在通过这个插件生成 DDL;该项目使用 JPA 进行持久化;因此该目标使用了 JPA 配置并且运行良好。
现在,当我使用相同版本的 hibernate-core 实现 hbm2cfgxml 和 hbm2java 时;hibernate annotation 3.5.6-FINAL(它使用hibernate-core 3.5.6-FINAL作为我排除的依赖项)和hibernate commons annotations 3.2.0.Final;它给出了 IncompatibleClassChangeError。我的插件配置:
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>hibernate3-maven-plugin</artifactId>
<version>2.2</version>
<executions>
<execution>
<id>hbm2cfgxml</id>
<phase>generate-resources</phase>
<goals>
<goal>hbm2cfgxml</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2cfgxml</name>
<implementation>jdbcconfiguration</implementation>
</component>
</components>
<componentProperties>
<ejb3>true</ejb3>
<packagename>foo.bar</packagename>
</componentProperties>
</configuration>
</execution>
<execution>
<id>hbm2java</id>
<phase>generate-sources</phase>
<goals>
<goal>hbm2java</goal>
</goals>
<configuration>
<components>
<component>
<name>hbm2java</name>
<implementation>annotationconfiguration</implementation>
</component>
</components>
<componentProperties>
<ejb3>true</ejb3>
<packagename>foo.bar</packagename>
<configurationfile>target/hibernate3/generated-mappings/hibernate.cfg.xml</configurationfile>
</componentProperties>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.16</version>
</dependency>
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>4.0.0.GA</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-entitymanager</artifactId>
<version>3.6.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>3.6.6.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate.javax.persistence</groupId>
<artifactId>hibernate-jpa-2.0-api</artifactId>
<version>1.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-c3p0</artifactId>
<version>3.6.6.Final</version>
<exclusions>
<exclusion>
<artifactId>slf4j-api</artifactId>
<groupId>org.slf4j</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-annotations</artifactId>
<version>3.5.6-Final</version>
<type>jar</type>
<scope>compile</scope>
<exclusions>
<exclusion>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</plugin>
</plugins>
和错误:
[错误] 无法在项目 dss-domain 上执行目标 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml (hbm2cfgxml):执行目标 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml 的 hbm2cfgxml失败:在执行 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings 时遇到 API 不兼容,但需要类
任何想法谁是罪魁祸首?新的休眠版本或插件(可能需要更新,因为它似乎在 2.2 上已经有一段时间了。