簡體   English   中英

線程“主”中的異常java.lang.NoClassDefFoundError:javax / persistence / Cacheable

[英]Exception in thread “main” java.lang.NoClassDefFoundError:javax/persistence/Cacheable

我在創建表的Java中有一個簡單的休眠模式。 執行時是異常。

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)

在項目構建路徑中添加hibernate-jpa-2.0-api-1.0.0.Final庫。 Maven Repo下載它。 其他版本在這里可用。

通過包含hibernate-jpa-2.0-api-1.0.0,可以解決此錯誤。 在您的類路徑中,可以在hibernate-distribution-3.5.3-Final \\ lib \\ jpa中找到。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM