org.hibernate.MappingNotFoundException: resource: Students.hbm.xml not found at org.hibernate.cfg.Configuration.addResource(Configuration.java:738) at org.hibernate.cfg.Configuration.parseMappingElement(Configuration.java:2188) at org.hibernate.cfg.Configuration.parseSessionFactory(Configuration.java:2160) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2140) at org.hibernate.cfg.Configuration.doConfigure(Configuration.java:2093) at org.hibernate.cfg.Configuration.configure(Configuration.java:2008) at org.hibernate.cfg.Configuration.configure(Configuration.java:1987) at com.imooc.test.StudentsTest.init(StudentsTest.java:25) 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:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:27) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 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)java.lang.NullPointerException at com.imooc.test.StudentsTest.destory(StudentsTest.java:49) 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:45) at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15) at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42) at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:36) at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68) at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47) at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231) at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60) at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229) at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50) at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222) at org.junit.runners.ParentRunner.run(ParentRunner.java:300) 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)
4 回答
慕仔7064047
TA贡献1条经验 获得超0个赞
如果你报了org.hibernate.MappingNotFoundException: resource: Students.hbm.xml not found
这个错误,那么可能和我错的是一样的。
原因是:有时我们在src下创建xml文件时,这个xml文件并没有生成在src下,而是生成在了我导入的jar包下(我的是生成在了mysql-jdbc下了),那么需要做的是将mysql-jdbc下的xml文件挪到src下就好了,因为这个错误原因就是找不到Students.hbm.xml这个文件。
另外有时我在src下创建包时,这个包也会莫名其妙的会创建在其他位置,但是我们刷新一下就会好了
qq_風是鹹的_0
TA贡献15条经验 获得超5个赞
找不到hibernae的映射文件 Students.hbm.xml
创建映射文件 Students.hbm.xml
在hibernate配置文件中添加映射路径
逆光之羽
TA贡献55条经验 获得超13个赞
Students.hbm.xml这个文件要不然没写 要不然名字和实体类不一致
要不然hibernate.cfg.xml文件里面没写<mapping resource="com/imooc/entity/Student.hbm.xml"/>这样的映射文件路径指定语句,或者指定的包路径不正确
能想到的就这些
添加回答
举报
0/150
提交
取消