java.lang.NoSuchMethodError:org.hibernate.cfg.Configuration.addAnnotatedClass [英] java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass

查看:2051
本文介绍了java.lang.NoSuchMethodError:org.hibernate.cfg.Configuration.addAnnotatedClass的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的JPA&安培;冬眠,当我尝试这个教程
我增加了以下提供商在我的persistence.xml,

I am new to JPA & hibernate, when I try this tutorial . I added the following provider in my persistence.xml,

<provider>org.hibernate.ejb.HibernatePersistence</provider> 

和我收到此错误。

log4j:WARN No appenders could be found for logger (org.jboss.logging).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
Exception in thread "main" java.lang.NoSuchMethodError: org.hibernate.cfg.Configuration.addAnnotatedClass(Ljava/lang/Class;)Lorg/hibernate/cfg/Configuration;
    at org.hibernate.ejb.Ejb3Configuration.addAnnotatedClass(Ejb3Configuration.java:1421)
    at org.hibernate.ejb.Ejb3Configuration.addNamedAnnotatedClasses(Ejb3Configuration.java:1391)
    at org.hibernate.ejb.Ejb3Configuration.addClassesToSessionFactory(Ejb3Configuration.java:1184)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:1048)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:291)
    at org.hibernate.ejb.Ejb3Configuration.configure(Ejb3Configuration.java:373)
    at org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
    at javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)
    at de.vogella.jpa.simple.main.Main.main(Main.java:17)

请帮助解决这个错误。
谢谢

Kindly help to resolve this error . Thank you

推荐答案

它看起来像Hibernate的注解罐子是错误的。它不与罐子版本兼容。所以这就是为什么它显示了java.lang.NoSuchMethodError

It look like the Hibernate Annotation jar is wrong. It is not compatible with the jar version. So that is why it showing the "java.lang.NoSuchMethodError"

能否请你告诉我哪个罐子的版本,你目前的工作,请指定版本?
那么只有我们能够轻松地解决这个问题。

Could you please tell me the which jar version are you currently working , please specify the version ? Then only we have to easily address this.

哪个版本的Hibernate你目前的工作?

Which Hibernate version are you currently working ?

哪个版本的注释,你目前的工作?

Which Annotation version are you currently working ?

请指定版本。
 谢谢你。

please specify the version. Thanks.

这篇关于java.lang.NoSuchMethodError:org.hibernate.cfg.Configuration.addAnnotatedClass的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆