码迷,mamicode.com
首页 > 移动开发 > 详细

IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

时间:2019-10-01 11:37:30      阅读:106      评论:0      收藏:0      [点我收藏+]

标签:mapper   state   oda   find   parent   invoke   not   org   comm   

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

    at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:227)
    at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:49)
    at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:65)
    at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:58)
    at com.sun.proxy.$Proxy8.findAll(Unknown Source)
    at com.rao.UserTest.func02(UserTest.java:37)
    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:47)
    at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
    at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
    at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
    at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
    at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
    at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
    at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
    at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
    at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
    at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
    at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
    at org.junit.runner.JUnitCore.run(JUnitCore.java:160)
    at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)

 

上面是错误信息,就是说UserMapper.java和UserMapper.xml不匹配,查了几个小时的资料,各种方法都试了,感觉最好的一篇是下面这一篇,各位可以看一下:

https://blog.csdn.net/ppppfly/article/details/46847299

不过这也没有解决我的问题,不管怎么查看,包名,类名,方法名,方法参数类型,所有的东西都配置对了,还是报错,后来我又在resources下建了一个包,结果出现了下面这种情况:

技术图片

 

 发现com.rao.mapper和com.rao.pojo居然没有合在一起,说明这两个包的前两级目录没有重合,然后我就到项目的目录下区看,发现包的名称如下图所示:

技术图片

 

 com.rao.pojo居然成了1个包,不是3个包!!!!!!!!!!!!!

以前在IDEA里面建包时,直接创建com.rao.pojo是被创建成三个包的:com  rao  pojo,结果这里就成了一个包,叫做 :com.rao.pojo

这样建立包结构java和xml肯定不会匹配,后来把包分步建立,就成功了,不报错了,这里真的巨坑!!!!!!!!

 

IDEA+Maven+Mybatis 巨坑:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rao.mapper.UserMapper.findAll

标签:mapper   state   oda   find   parent   invoke   not   org   comm   

原文地址:https://www.cnblogs.com/rao11/p/11614820.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!