休眠AnnotationConfiguration已弃用...但在MappingException中使用配置结果 [英] hibernate AnnotationConfiguration is deprecated... but using Configuration results in MappingException
问题描述
这是我的代码:
Here is my code:
Configuration config = new Configuration().configure();
给出:
which gives :
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>
请帮助!!!
Help please!!!
推荐答案
事实证明,我的两个不同版本的hibernate在我的classpath中。一旦我解决了这个问题,并使用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!
这篇关于休眠AnnotationConfiguration已弃用...但在MappingException中使用配置结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!