idea开发出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
2018-08-19 13:28
609 查看
本人用Idea开发,出现如下Bug:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.younger.dao.UserMapper.findById at org.apache.ibatis.binding.MapperMethod$SqlCommand.<init>(MapperMethod.java:189) at org.apache.ibatis.binding.MapperMethod.<init>(MapperMethod.java:43) at org.apache.ibatis.binding.MapperProxy.cachedMapperMethod(MapperProxy.java:58) at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:51) at com.sun.proxy.$Proxy12.findById(Unknown Source) at UserMapperTest.fun01(UserMapperTest.java:24) 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.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26) 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.runners.Suite.runChild(Suite.java:128) at org.junit.runners.Suite.runChild(Suite.java:27) 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: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对应上。
解决过程:
- 先对应代理接口和xml的名称是否一致,比如接口名,接口所在的包,接口的方法,接口的参数,接口的返回值类型是否和xml配置中一致。
然后发现都一致,并没有什么问题。 - 查看target下输出的文件,如下:
可以看到我的dao包下面明明有UserMapper.java和UserMapper.xml两个文件的,然而target下输出的只有UserMapper.java
这说明UserMapper.xml并没有被运行。
原因是idea自动过滤掉了src/main/java下的配置文件,因为一般配置文件都是放在src/main/resource下的。
两种解决方案:
一:是在src/main/resource下创建和UserMapper.java同样的包路径,将UserMapper.xml放入其中就可以了
二:在pom.xml下添加如下:
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </includes> </resource> <resource> <directory>src/main/resources</directory> </resource> </resources> </build>阅读更多
相关文章推荐
- IDEA的maven项目出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- ssm整合出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
- mybatis maven打包出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
- mybatis错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis绑定错误:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- MyBatis Error:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)(IDEA)
- IDEA异常解决: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误解决方法
- Idea+myBatis报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- 关于整合SSH,出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- mybatis整合springmvc时的错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found
- mybatis绑定错误org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误记录
- 出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)的解决方法
- 解决org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)错误
- 当mybatis整合spring后出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):
- mybatis出现org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
- mybatis使用时org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):的错误
- idea报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.money.*