“线程中的异常”;“主要”;NoClassDefFoundError:javax/persistence/Cacheable
我用java编写了一个简单的hibernate来创建表。执行时是异常的“线程中的异常”;“主要”;NoClassDefFoundError:javax/persistence/Cacheable,java,hibernate,console-application,Java,Hibernate,Console Application,我用java编写了一个简单的hibernate来创建表。执行时是异常的 public class TestEmployee { public static void main(String[] args) { AnnotationConfiguration config = new AnnotationConfiguration(); config.addAnnotatedClass(Employee.class); config.conf
public class TestEmployee {
public static void main(String[] args) {
AnnotationConfiguration config = new AnnotationConfiguration();
config.addAnnotatedClass(Employee.class);
config.configure();
new SchemaExport(config).create(true, true);
}
}
例外情况是:
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java: 988)
at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:579)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002 )
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:130)
at org.hibernate.tool.hbm2ddl.SchemaExport.<init>(SchemaExport.java:92)
at com.Hibernate.chapter1.TestEmployee.main(TestEmployee.java:15)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
at java.net.URLClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
线程“main”java.lang.NoClassDefFoundError中的异常:javax/persistence/Cacheable
位于org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java:988)
位于org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:579)
位于org.hibernate.cfg.Configuration$MetadataSourceQueue.processAnnotatedClassesQueue(Configuration.java:4035)
位于org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3989)
位于org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
位于org.hibernate.cfg.Configuration.generateDropSchemaScript(Configuration.java:1002)
位于org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:130)
位于org.hibernate.tool.hbm2ddl.SchemaExport.(SchemaExport.java:92)
位于com.Hibernate.chapter1.TestEmployee.main(TestEmployee.java:15)
原因:java.lang.ClassNotFoundException:javax.persistence.Cacheable
位于java.net.URLClassLoader.findClass(未知源)
位于java.lang.ClassLoader.loadClass(未知源)
位于sun.misc.Launcher$AppClassLoader.loadClass(未知源)
位于java.lang.ClassLoader.loadClass(未知源)
添加
hibernate-jpa-2.0-api-1.0.0。项目构建路径中的最终
库。从下载它。其他版本可用。此错误可以通过包含hibernate-jpa-2.0-api-1.0.0来解决。在您的类路径中,可以在hibernate-distribution-3.5.3-Final\lib\jpa中找到