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文件在不在

Invalid bound statement (not found)出现原因和解决方法

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>

Original: https://www.cnblogs.com/b10100912/p/16727862.html
Author: 学习钱厚端的小白
Title: Invalid bound statement (not found)出现原因和解决方法

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/615795/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球