我是JPA&hibernate的新手。我在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)
请帮助解决此错误。谢谢
看起来像Hibernate Annotationjar是错误的。它与jar版本不兼容。这就是为什么它显示"java.lang.NoSuchMethodError"
"java.lang.NoSuchMethodError"
您能否告诉我您当前正在使用哪个jar版本,请指定版本?然后,只有我们必须轻松解决此问题。
您当前正在使用哪个Hibernate版本?
您当前正在使用哪个注释版本?
请指定版本。谢谢。