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

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

问题描述

我是 JPA 的新手 &休眠,当我尝试这个 tutorial 时.我在我的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 Annotation jar 是错误的.它与 jar 版本不兼容.所以这就是为什么它显示 "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"

能否请您告诉我您当前使用的是哪个 jar 版本,请指定版本?那么只有我们才能轻松解决这个问题.

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 ?

您目前使用的是哪个 Annotation 版本?

Which Annotation version are you currently working ?

请指定版本.谢谢.

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

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