hibernate 3.5 运用annotation 缺少 jpa的错误

Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/Cacheable
 at org.hibernate.cfg.AnnotationBinder.determineCacheSettings(AnnotationBinder.java:946)
 at org.hibernate.cfg.AnnotationBinder.bindClass(AnnotationBinder.java:589)
 at org.hibernate.cfg.AnnotationConfiguration.processArtifactsOfType(AnnotationConfiguration.java:636)
 at org.hibernate.cfg.AnnotationConfiguration.secondPassCompile(AnnotationConfiguration.java:359)
 at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1377)
 at org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
 at TeacherTest.main(TeacherTest.java:16)
Caused by: java.lang.ClassNotFoundException: javax.persistence.Cacheable
 at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
 at java.security.AccessController.doPrivileged(Native Method)
 at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:307)
 at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301)
 at java.lang.ClassLoader.loadClass(ClassLoader.java:252)
 at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:320)
 ... 7 more

 

错误原因,javax.persistence.Cacheable 是 JPA 2.0 规范中的东西!

支持 JPA 2 的 Hibernate 实现 3.5 版目前还处于 CR2 版本之中,还没有正式发布。

需要在加入hibernate-distribution-3.5.0-Final\lib\jpa目录下的hibernate-jpa-2.0-api-1.0.0.Final.jar

你可能感兴趣的:(hibernate 3.5 运用annotation 缺少 jpa的错误)