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>
posted @ 2022-09-25 14:52  面向CV工程师  阅读(742)  评论(0编辑  收藏  举报