Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xslt/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
“线程中的异常”;“主要”;NoClassDefFoundError:javax/persistence/Cacheable_Java_Hibernate_Console Application - Fatal编程技术网

“线程中的异常”;“主要”;NoClassDefFoundError:javax/persistence/Cacheable

“线程中的异常”;“主要”;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

我用java编写了一个简单的hibernate来创建表。执行时是异常的

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中找到