springboot整合mybatis时报错解决

395 阅读1分钟

在使用springboot整合mybatis时,一直报错:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)

无效的绑定,其实是因为在打包时,没有把Mapper.xml文件打包进去,可以去target下的对应目录中看下,如果确实没有这个.xml文件,就说明是这个原因。
解决方案是在pom文件中加入配置,使其打包时能够将
Mapper.xml文件打包进去。 在build的标签下,resources标签下加入下列代码

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

因为我的*Mapper.xml文件在java目录下,所以这么去写