hibernate一个易犯的错误

今天编写一个hibernate程序,平时总是不会忘了把hibernate-jpa-2.0-api-1.0.0.Final.jar这个包导入工程,今天忘记了,出现了下面的异常:

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:1355)

at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1826)

at com.zhang.bean.Test.testSave2(Test.java:16)

at com.zhang.bean.Test.main(Test.java:11)

Caused by: java.lang.ClassNotFoundException: javax.persistence.EntityListeners

at java.net.URLClassLoader$1.run(Unknown Source)

at java.security.AccessController.doPrivileged(Native Method)

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)

... 6 more

由于是初学者,所以看到这样的异常总是一筹莫展,谷歌一下,找到错误原因,所以说异常也是要收集的。

你可能感兴趣的:(Hibernate)