Invalid bound statement (not found)出现原因和解决方法
Invalid bound statement (not found)出现原因和解决方法
前言:
想必各位小伙伴在码路上经常会碰到奇奇怪怪的事情,比如出现Invalid bound statement (not found),那今天我就来分析以下出现此问题的原因。
其实出现这个问题实质就是mapper接口和mapper.xml文件没有映射起来。
常见的错误如下:
1.mapper.xml中的namespace和实际的mapper文件不一致
这个问题其实很好解决,瞪大眼睛,仔仔细细看看,到底对不对应不就好了嘛
2.mapper接口中的方法名和mapper.xml中的id标签不一致
这个问题和上个问题解决方法一样,仔细对对嘛,这个再对不出来,面壁思过吧。
3.上两步的问题都没有,但是还是不行,可能原因就是,没有构建进去,打开target看看对应的mapper.xml文件在不在
4.pom.xml文件中配置resource,不然mapper.xml文件就会被漏掉!pom.xml的中配置了resource,bug消失了~
<!-- 如果不添加此节点mybatis的mapper.xml文件都会被漏掉。 --> <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>
分类:
Mybatis-Plus知识点
, Spring-Boot
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术