java.lang.ClassNotFoundException: javax.persistence.EntityListeners
Exception in thread "main" java.lang.NoClassDefFoundError: javax/persistence/EntityListeners at org.hibernate.cfg.annotations.reflection.JPAMetadataProvider.getDefaults(JPAMetadataProvider.java:96) at org.hibernate.annotations.common.reflection.java.JavaReflectionManager.getDefaults(JavaReflectionManager.java:226) at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1385) at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856) at com.jxd.StudentTest.main(StudentTest.java:21)Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners at java.net.URLClassLoader$1.run(URLClassLoader.java:202) at java.security.AccessController.doPrivileged(Native Method) at java.net.URLClassLoader.findClass(URLClassLoader.java:190) at java.lang.ClassLoader.loadClass(ClassLoader.java:306) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:301) at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
... 5 more
出错原因: 这是因为Hibernate 3.6依赖JPA,因此必须在class path 中包含一个JPA jar包。 You can find one in the Hibernate 解决方案:在class path中包含hibernate-jpa-2.0-api-1.0.0.Final.jar包即可。该包可在Hibernate-distribution-3.6.0.Final/lib/目录下找到
posted on 2016-05-28 16:55 nickTimer 阅读(1516) 评论(0) 编辑 收藏 举报