2011-09-21 134 views
2

我已成功使用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配置并运行良好。hibernate3-maven-plugin:在依赖关系中更新Hibernate版本(3.6.6-FINAL)

现在,当我实现hbm2cfgxml和hbm2java使用相同版本的hibernate-core; hibernate注释3.5.6-FINAL(它使用hibernate-core 3.5.6-FINAL作为我排除的依赖)和hibernate commons注释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> 

和错误:

[ERROR] Failed to execute goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml (hbm2cfgxml) on project dss-domain: Execution hbm2cfgxml of goal org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml failed: An API incompatibility was encountered while executing org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml: java.lang.IncompatibleClassChangeError: Found interface org.hibernate.cfg.Mappings, but class was expected

任何想法谁是罪魁祸首?新的休眠版本或插件(这可能需要更新,因为它似乎在2.2相当长的一段时间。

回答

2

我猜测问题是Hibernate Tools。我认为当前的稳定版本(3.2.4.GA)与Hibernate Core 3.3.X兼容,当前的git master(https://github.com/hibernate/hibernate-tools)与Hibernate Core 3.5.X兼容。您可以尝试安装其中一个github Hibernate Tools分支并声明在Hibernate3-Maven的插件,它依赖

https://github.com/axiomalaska/hibernate-tools/tree/3.6.X - 休眠3.6.x的(披露:我的叉子)。

https://github.com/dgeraskov/hibernate-tools/tree/hibernate4 - 休眠4.X