一.复现
在我springboot项目,启动的时候,报了Invalid bound statement (not found) :绑定语句无效(未找到)
二.原因
mapper接口和mapper.xml文件没有映射起来
三.解决
1.查看mapper.xml中的namespace和接口mapper文件一致吗
2.看一下 target 里面有没有编译的mapper.xml文件
文章来源:https://www.toymoban.com/news/detail-621823.html
没有的话,打开maven点击clean一下,重新运行就ok了。文章来源地址https://www.toymoban.com/news/detail-621823.html
3.检查pom.xml文件中是否配置resource,不然mapper.xml文件不会被编译到 target。
<!-- 如果不配置resource,mapper.xml文件不会被加载到target,就会报找不到的错误。 -->
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
到了这里,关于Invalid bound statement (not found) 原因和解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!