在IDEA 中使用 Mybatis 出现Invalid bound statement (not found)问题的解决

版权声明:Impassive https://blog.csdn.net/Impassive_y/article/details/81986297

今天在学习Mybatis的过程中出现了Invalid bound statement (not found)问题,在网上找了很多解决办法,综合有如下几点:

1:检查XML文件是否和interface文件在同一个目录下;

2:检查XML文件的namespace 是否和interface 的全类名相同,主义,如果此时主配置中也配置有mapper ,将他删掉,否则会出现Type interface XXX is already known to the MapperRegistry异常;

3:所调用的方法在XML中是否存在,且id名字和方法名是否相同;

4:配置的返回值是否正确;

5:路径是否正确

还有的说IDEA编译时不会加载source下的XML文件,但是楼主没有遇到这个问题,若存在此问题,在pom文件中添加以下代码

<resource>
    <directory>src/main/resource</directory>
    <includes>
        <include>**/*.*</include>
    </includes>
</resource>
<resource>
    <directory>src/main/source</directory>
    <includes>
        <include>**/*.*</include>
    </includes>
    <filtering>true</filtering>
</resource>

若有不同意见,欢迎指出

猜你喜欢

转载自blog.csdn.net/Impassive_y/article/details/81986297