报错处理:java.io.IOException: Could not find resource mybatis-config.xml

发布时间:2024年01月06日

?运行mybatis文件时出现了以下的情况

java.io.IOException: Could not find resource mybatis-config.xml
? ? at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:114)
? ? at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:100)
? ? at org.apache.ibatis.io.Resources.getResourceAsReader(Resources.java:160)
? ? at Test.UserTest.userFindByIdTest(UserTest.java:22)
? ? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
? ? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
? ? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
? ? at java.lang.reflect.Method.invoke(Method.java:498)
? ? 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.junit.runner.JUnitCore.run(JUnitCore.java:137)
? ? at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
? ? at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
? ? at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
? ? at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
? ? at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
? ? at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)
?
java.lang.NullPointerException
? ? at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:56)
? ? at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:36)
? ? at Test.UserTest.userFindByIdTest(UserTest.java:28)
? ? at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
? ? at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
? ? at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
? ? at java.lang.reflect.Method.invoke(Method.java:498)
? ? 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.junit.runner.JUnitCore.run(JUnitCore.java:137)
? ? at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:69)
? ? at com.intellij.rt.junit.IdeaTestRunner$Repeater$1.execute(IdeaTestRunner.java:38)
? ? at com.intellij.rt.execution.junit.TestsRepeater.repeat(TestsRepeater.java:11)
? ? at com.intellij.rt.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:35)
? ? at com.intellij.rt.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:235)
? ? at com.intellij.rt.junit.JUnitStarter.main(JUnitStarter.java:54)

原因分析:

在构建的文件中没有找到下图文件

是因为没有将resources文件夹进行标注

解决方法:

?

最后再重新构建一下即可正常运行

文章来源:https://blog.csdn.net/m0_64335844/article/details/135432232
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。