我想尝试一下Hibernate,但我得到以下异常:
Exception in thread "main" java.lang.NoSuchFieldError: namingStrategy
at org.hibernate.cfg.AnnotationConfiguration.reset(AnnotationConfiguration.java:250)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:125)
at org.hibernate.cfg.Configuration.<init>(Configuration.java:119)
at org.hibernate.cfg.AnnotationConfiguration.<init>(AnnotationConfiguration.java:108)
at android.server.HibernateTest.main(HibernateTest.java:9)
这是我尝试运行的课程:
package android.server;
import org.hibernate.cfg.AnnotationConfiguration;
import org.hibernate.tool.hbm2ddl.SchemaExport;
public class HibernateTest {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Dish.class);
config.configure("hibernate.cfg.xml");
new SchemaExport(config).create(true, true);
}
}
这些是Maven Dependencies中的jar:
asm-3.3.1.jar
jersey-bundle-1.19.jar
jsr311-api-1.1.1.jar
json-20140107.jar
jersey-server-1.19.jar
jersey-core-1.19.jar
gson-2.2.4.jar
hibernate-core-5.0.7.Final.jar
jboss-logging-3.3.0.Final.jar
hibernate-jpa-2.1-api-1.0.0.Final.jar
javassist-3.18.1-GA.jar
antlr-2.2.7.jar
geronimo-jta_1.1_spec-1.1.1.jar
jandex-2.0.0.Final.jar
dom4j-1.6.1.jar
xml-apis-1.0.b2.jar
hibernate-commons-annotations-5.0.1.Final.jar
hibernate-annotations-3.4.0.GA.jar
ejb3-persistence-1.0.2.GA.jar
hibernate-commons-annotations-3.1.0.GA.jar
mysql-connector-java-5.1.38.jar
slf4j-api-1.7.14.jar
slf4j-log4j12-1.7.14.jar
log4j-1.2.17.jar
有人能帮助我吗?我不知道是什么原因引起了这个问题。 谢谢!