SpringBoot整合mybatis报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

在使用SpringBoot整合mybatis时一直报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

提示信息大概是mapper.xml和mapper.java无法绑定。

首先,需要先检查一下

1、mapper接口和mapper.xml是否在同一个包(package)下?名字是否一样(仅后缀不同)?

2、mapper.xml中namespace是否对应,id是否对应接口方法名称

检查之后发现没问题,

最后找到了一个解决方案,编译代码以后去编译路径下查看对应的mapper.xml和mapper.java是否编译成功。

我这里看了以后发现就是xml没有编译进来,

然后因为是maven项目,在pom.xml的<build></build>里面,加这么一段:

        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.xml</include>
                </includes>
                <filtering>true</filtering>
            </resource>
        </resources>     

再次运行项目,重新编译以后就会显示出来了。

然后发现SpringBoot整合mybatis成功!

本文解决方法参考:

原文:https://blog.csdn.net/ppppfly/article/details/46847299/

原文地址:https://www.cnblogs.com/Zlcode/p/10808175.html