org.hibernate.InvalidMappingException: Could not parse mapping document from resource

今天遇到了一个坑,给大家分享一下,自己从毕业开始就一直写android,Java框架类的也忘了差不多了。

下面是错误日志:

org.hibernate.InvalidMappingException: Could not parse mapping document from resource com/test/www/User.hbm.xml
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4009)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXmlQueue(Configuration.java:3998)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processMetadata(Configuration.java:3986)
at org.hibernate.cfg.Configuration.secondPassCompile(Configuration.java:1398)
at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1856)
at com.test.www.Test01.fun1(Test01.java:14)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:678)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: org.hibernate.MappingException: class com.test.www.User.User not found while looking for property: id
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:232)
at org.hibernate.mapping.SimpleValue.setTypeUsingReflection(SimpleValue.java:316)
at org.hibernate.cfg.HbmBinder.bindSimpleId(HbmBinder.java:454)
at org.hibernate.cfg.HbmBinder.bindRootPersistentClassCommonValues(HbmBinder.java:387)
at org.hibernate.cfg.HbmBinder.bindRootClass(HbmBinder.java:326)
at org.hibernate.cfg.HbmBinder.bindRoot(HbmBinder.java:177)
at org.hibernate.cfg.Configuration$MetadataSourceQueue.processHbmXml(Configuration.java:4006)
... 28 more
Caused by: java.lang.ClassNotFoundException: com.test.www.User.User
at java.net.URLClassLoader$1.run(Unknown Source)
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)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Unknown Source)
at org.hibernate.util.ReflectHelper.classForName(ReflectHelper.java:192)
at org.hibernate.util.ReflectHelper.reflectedPropertyClass(ReflectHelper.java:228)
... 34 more

其实在日志的最后一句已经说得很明白了,就是找不到类,因为我在复制的时候,直接复制了完整路径,结果找了半个多小时,因为现在大家都用注解了,所以也很少会出现这种问题,但是,我想给自己说的一句话就是,不管干嘛都要细心,其实都不难,是我门太悲观。在重新温习旧知识的时候一定要有耐心,照着步骤来。最后就直接给大家解决办法了,因为这种低级错误只是用来提醒自己。

org.hibernate.InvalidMappingException: Could not parse mapping document from resource_第1张图片

你可能感兴趣的:(org.hibernate.InvalidMappingException: Could not parse mapping document from resource)