hibernate3-maven-plugin:与更新的 Hibernate 版本 (3.6.6-FINAL) 的依赖关系中断

发布于 2024-12-06 03:30:37 字数 5121 浏览 0 评论 0原文

我已成功将 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 注释 3.5.6-FINAL (它使用 hibernate-core 3.5.6-FINAL 作为我排除的依赖项)和 hibernate commons 注释 3.2.0.Final;它给出了 IncompleteClassChangeError 。我的插件配置:

<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>

和错误:

[错误] 未能执行目标 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml (hbm2cfgxml) 在项目 dss-domain 上:目标的执行 hbm2cfgxml org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml 失败:An 执行时遇到API不兼容的情况 org.codehaus.mojo:hibernate3-maven-plugin:2.2:hbm2cfgxml: java.lang.IncompleteClassChangeError:找到接口 org.hibernate.cfg.Mappings,但需要类

任何想法谁是罪魁祸首?新的 hibernate 版本或插件(可能需要更新,因为它似乎在 2.2 上已经存在很长一段时间了。

I have successfully used hibernate3-maven-plugin with Hibernate-Core and EntityManager 3.6.6-FINAL, hibernate-commons-annotations-3.2.0.Final, hibernate-jpa-2.0-api-1.0.1.Final and hibernate-validator-4.0.0.GA in recent past. I was generating the DDL through this plugin; the project used JPA for persistence; hence that goal used JPA Configuration and worked well.

Now, when I implement hbm2cfgxml and hbm2java using the same version of hibernate-core; hibernate annotation 3.5.6-FINAL (it uses hibernate-core 3.5.6-FINAL as dependency which I excluded) and hibernate commons annotations 3.2.0.Final; it gives IncompatibleClassChangeError. My plugin configuration:

<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>

And the Error:

[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

Any ideas who's the culprit? the new hibernate versions or plugin (which might require update as it seems to be on 2.2 for quite sometime.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

眼前雾蒙蒙 2024-12-13 03:30:37

我猜测问题出在 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-plugin 中声明对其的依赖关系。

https://github.com/axomalaska/hibernate-tools/tree/3.6.X - Hibernate 3.6.X(披露:我的叉子)

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

I'm guessing that the problem is Hibernate Tools. I think the current stable version (3.2.4.GA) is compatible with Hibernate Core 3.3.X and the current git master (https://github.com/hibernate/hibernate-tools) works with Hibernate Core 3.5.X. You might try installing one of these github Hibernate Tools forks and declaring a dependency on it in hibernate3-maven-plugin.

https://github.com/axiomalaska/hibernate-tools/tree/3.6.X - Hibernate 3.6.X (disclosure: my fork)

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文