springboot项目下的Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found):

今天遇到mybatis-puls的报错Caused by: org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

排查方法如下:

1、mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)?

2、mapper.xml的命名空间(namespace)是否跟mapper接口的包名一致?

3、接口的方法名,与xml中的一条sql标签的id一致

4、配置文件中的配置

#mybatis
mybatis-plus:
mapper-locations: classpath:**/*Mapper.xml

5、如果你的项目是maven项目,请你在编译后,到接口所在目录看一看,很有可能是没有生产对应的xml文件,因为maven默认是不编译的,因此,你需要在你的pom.xml的<build></build>里面,加这么一段:

<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources> 

我的问题就出在第5部,因为之前没怎么接触maven项目,所以新建项目后并没有在pom中加上编译的配置,导致一直找不到绑定失败。今把问题记录方便日后好进行回忆查看

猜你喜欢

转载自www.cnblogs.com/xiaokangk/p/12101415.html
今日推荐