AnnotationConfiguration

AnnotationConfiguration

本文介绍了hibernate AnnotationConfiguration 已弃用...但在 MappingException 中使用 Configuration 结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码:

        Configuration config = new Configuration().configure();

给出:

org.hibernate.MappingException: An AnnotationConfiguration instance is required to use <mapping class="com.google.musicstore.domain.Record"/>

很好...所以我尝试使用 org.hibernate.cfg.AnnotationConfiguration 代替:

fine... so I try to use org.hibernate.cfg.AnnotationConfiguration instead :

        Configuration config = new AnnotationConfiguration().configure();

但该类已被弃用.文档指示我改用配置!

but that class is deprecated. The docs instruct me to use Configuration instead!

作为旁注,AnnotationConfiguration 选项也失败,导致:

As a side note, the AnnotationConfiguration option fails also, resulting in :

Caused by: java.lang.IncompatibleClassChangeError: Implementing class

这是我的 pom.xml :

Here is my pom.xml :

    <dependency>
        <groupId>org.hibernate</groupId>
        <artifactId>hibernate-search</artifactId>
        <version>4.3.0.Final</version>
    </dependency>

请帮忙!!!

推荐答案

原来我的类路径中有两个不同版本的 hibernate.一旦我解决了这个问题并且只使用了 4.3.0.Final,一切都很好.傻我!

It turned out I had two different versions of hibernate lying around in my classpath. Once I resolved this and just used 4.3.0.Final, everything was fine. Silly me!

这篇关于hibernate AnnotationConfiguration 已弃用...但在 MappingException 中使用 Configuration 结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-20 11:57