2015-05-07 2 views
1

У меня есть простой спящий режим в java для создания таблицы. Это исключение при выполнении.Исключение в теме "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable

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) 

ответ

2

Добавить hibernate-jpa-2.0-api-1.0.0.Final библиотеку в путь сборки проекта. Загрузите его с Maven Repo. Другие версии доступны here.

-1

Эта ошибка может быть решена путем включения hibernate-jpa-2.0-api-1.0.0. в вашем пути к классам, который можно найти в hibernate-distribution-3.5.3-Final \ lib \ jpa.

Смежные вопросы