mybatis绑定错误 org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

如果出现:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

一般的原因是Mapper interface和xml文件的定义对应不上,需要检查包名,namespace,函数名称等能否对应上,需要比较细致的对比,我经常就是写错了一两个字母搞的很长时间找不到错误

按以下步骤一一执行:

1:检查xml文件所在的package名称是否和interface对应的package名称一一对应

2:检查xml文件的namespace是否和xml文件的package名称一一对应

3:检查函数名称能否对应上

4:去掉xml文件中的中文注释

5:随意在xml文件中加一个空格或者空行然后保存

6:确认 <property name="mapperLocations" value="classpath*:/mapper/ext/**/*DOMapper.xml"/> 位置 是否正确

7:在使用IDEA开发时,打包时,mapper没有自动复制到响应位置,也会出错

8:在pom.xml中的build里面加上   <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.xml</include> </include       s> <filtering>false</filtering> </resource> </resources>

猜你喜欢

转载自blog.csdn.net/u012184337/article/details/80195104