问答详情
源自:1-11 通过Hibernate API编写访问数据库的代码

这是什么问题

StudentsTest.testSaveStudents

testSaveStudents(hibernate_001.StudentsTest)

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 hibernate_001.StudentsTest.init(StudentsTest.java:26)


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


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


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 hibernate_001.StudentsTest.destory(StudentsTest.java:40)


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


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


at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)


at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)




提问者:宁敏 2016-09-15 21:17

个回答

  • qq_一台设备两种生活_0
    2016-09-16 14:18:16
    已采纳

    http://img.mukewang.com/57db8e7e000117b909530425.jpg

    要加入完整的类路径 包名+类名

  • 你就是未来
    2016-09-27 12:38:31

    能看看楼主的代码文件结构  我也遇到相同问题