新版本 Hibernate 的 hibernate3-maven-plugin 依赖项

发布于 2024-08-30 07:53:51 字数 2521 浏览 6 评论 0原文

我想将 hibernate-3.5-1.Final 与此插件一起使用,这里我的依赖项应该是什么。它似乎正在拿起一组旧的罐子,但现在失败了。

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
            </plugin>

编辑1:

[INFO] class org.hibernate.cfg.ExtendedMappings has interface org.hibernate
.cfg.Mappings as super class
[INFO] --------------------------------------------------------------------
----
[INFO] Trace
java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMap
pings has interface org.hibernate.cfg.Mappings as super class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja
va:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmC
lassLoader.java:195)
        at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClas
sRealm.java:255)
        at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLo
ader.java:214)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings
(AnnotationConfiguration.java:187)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Anno
tationConfiguration.java:277)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java
:1206)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configurat
ion.java:1226)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListe
nerConfigurator.java:173)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:854)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:191)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:253)

I would like to use hibernate-3.5-1.Final along with this plugin, what should be my dependencies here. It seems to be picking up a older set of jars and failing right now.

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>hibernate3-maven-plugin</artifactId>
                <version>2.2</version>
            </plugin>

EDIT1:

[INFO] class org.hibernate.cfg.ExtendedMappings has interface org.hibernate
.cfg.Mappings as super class
[INFO] --------------------------------------------------------------------
----
[INFO] Trace
java.lang.IncompatibleClassChangeError: class org.hibernate.cfg.ExtendedMap
pings has interface org.hibernate.cfg.Mappings as super class
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:621)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.ja
va:124)
        at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
        at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
        at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
        at org.codehaus.classworlds.RealmClassLoader.loadClassDirect(RealmC
lassLoader.java:195)
        at org.codehaus.classworlds.DefaultClassRealm.loadClass(DefaultClas
sRealm.java:255)
        at org.codehaus.classworlds.RealmClassLoader.loadClass(RealmClassLo
ader.java:214)
        at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
        at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
        at org.hibernate.cfg.AnnotationConfiguration.createExtendedMappings
(AnnotationConfiguration.java:187)
        at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(Anno
tationConfiguration.java:277)
        at org.hibernate.cfg.Configuration.buildMappings(Configuration.java
:1206)
        at org.hibernate.ejb.Ejb3Configuration.buildMappings(Ejb3Configurat
ion.java:1226)
        at org.hibernate.ejb.EventListenerConfigurator.configure(EventListe
nerConfigurator.java:173)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:854)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:191)
        at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.
java:253)

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

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

发布评论

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

评论(5

尤怨 2024-09-06 07:53:51

我能够使用以下依赖项集(即所有 hibernate jar 的 3.5.1-Final)来实现此功能

                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate-core.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate-entitymanager.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-annotations</artifactId>
                        <version>${hibernate-annotations.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>ejb3-persistence</artifactId>
                        <version>3.3.2.Beta1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-tools</artifactId>
                        <version>${hibernate-tools.version}</version>
                    </dependency>
                </dependencies>

I was able to get this working with the following set of dependencies (i.e. 3.5.1-Final for all hibernate jars)

                <dependencies>
                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-core</artifactId>
                        <version>${hibernate-core.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-entitymanager</artifactId>
                        <version>${hibernate-entitymanager.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-annotations</artifactId>
                        <version>${hibernate-annotations.version}</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>ejb3-persistence</artifactId>
                        <version>3.3.2.Beta1</version>
                    </dependency>

                    <dependency>
                        <groupId>org.hibernate</groupId>
                        <artifactId>hibernate-tools</artifactId>
                        <version>${hibernate-tools.version}</version>
                    </dependency>
                </dependencies>
陈甜 2024-09-06 07:53:51

很难说到底发生了什么,但事实是 2.2 版本。 hibernate3-maven-plugin 声明 hibernate-core 3.3.1.GAhibernate-tools 3.2.3.GA 作为依赖项并进行编译反对这些版本。你尝试过更换它们吗?如果是,我认为你不能(特别是因为它们似乎引入了不兼容的更改)。

话虽如此,这不应该阻止您将 hibernate-entitymanager-3.5.1-Final 声明为项目中的依赖项并让插件使用其他版本(这应该是默认行为)。

It's hard to say what is happening exactly but the fact is that the version 2.2. of hibernate3-maven-plugin declares hibernate-core 3.3.1.GA and hibernate-tools 3.2.3.GA as dependencies and is compiled against those versions. Did you try to replace them? If yes, I don't think you can (especially since they seem to introduce non compatible changes).

Having that said, this shouldn't prevent you from declaring hibernate-entitymanager-3.5.1-Final as dependency in your project and let the plugin use other versions (which should be the default behavior).

夏了南城 2024-09-06 07:53:51

我有类似的问题。

运行“mvn dependency:tree”后,我看到unitils-dbunit:3.1依赖于较旧的hibernate.jar...

[INFO] +- org.unitils:unitils-dbunit:jar:3.1:test
[INFO] |  +- org.unitils:unitils-core:jar:3.1:test
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1:test
[INFO] |  |  +- commons-lang:commons-lang:jar:2.5:test (version managed from 2.3)
[INFO] |  |  \- ognl:ognl:jar:2.6.9:test
[INFO] |  +- org.unitils:unitils-database:jar:3.1:test
[INFO] |  |  +- org.unitils:unitils-dbmaintainer:jar:3.1:test
[INFO] |  |  |  \- org.hibernate:hibernate:jar:3.2.5.ga:test

将Hibernate库移至unitils依赖项之前解决了问题。顺序很重要。

祝你好运,
J。

I had a similar issue.

After running "mvn dependency:tree", I saw that unitils-dbunit:3.1 depended on an older hibernate.jar...

[INFO] +- org.unitils:unitils-dbunit:jar:3.1:test
[INFO] |  +- org.unitils:unitils-core:jar:3.1:test
[INFO] |  |  +- commons-logging:commons-logging:jar:1.1:test
[INFO] |  |  +- commons-lang:commons-lang:jar:2.5:test (version managed from 2.3)
[INFO] |  |  \- ognl:ognl:jar:2.6.9:test
[INFO] |  +- org.unitils:unitils-database:jar:3.1:test
[INFO] |  |  +- org.unitils:unitils-dbmaintainer:jar:3.1:test
[INFO] |  |  |  \- org.hibernate:hibernate:jar:3.2.5.ga:test

Moving the Hibernate libs before the unitils dependency solved the problem. Order matters.

Good luck,
J.

云裳 2024-09-06 07:53:51

对于 Hibernate 3.6.0.Final 我设置插件如下:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>3.0.1301</version>
        </dependency>
    </dependencies>
</plugin>

For Hibernate 3.6.0.Final I setup the plugin as follows:

<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>hibernate3-maven-plugin</artifactId>
    <version>2.2</version>
    <dependencies>
        <dependency>
            <groupId>xerces</groupId>
            <artifactId>xercesImpl</artifactId>
            <version>2.9.1</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-core</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
            <version>3.6.0.Final</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-validator</artifactId>
            <version>4.1.0.Final</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft</groupId>
            <artifactId>sqljdbc4</artifactId>
            <version>3.0.1301</version>
        </dependency>
    </dependencies>
</plugin>
玩世 2024-09-06 07:53:51

这个解决方案对我来说是最好的。只需添加一个依赖项,它将添加其余必要的依赖项:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.1.Final</version>
</dependency>

此处的最新版本: http: //mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager

This solution is the best for me. Just add one dependency, and it will add the rest of necesary dependencies:

<dependency>
    <groupId>org.hibernate</groupId>
    <artifactId>hibernate-entitymanager</artifactId>
    <version>4.2.1.Final</version>
</dependency>

Latest version here: http://mvnrepository.com/artifact/org.hibernate/hibernate-entitymanager

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