今天做项目遇到以前的知识,回顾一下,报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
其实就是接口和mapper没有对上,maven机制就只将java下的文件打包,没有将其他类型打包!
解决方式1:
直接手动复制.xml文件到target中去,完成手动打包!!!
解决方式2:
(1)首先我们要在项目依赖中添加如下依赖:
<!-- 项目打包时会将java目录中的*.xml文件也进行打包 -->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
解释一下为什么是两个*号,这其实就是代表多级目录,如果一个*,就是com
(2) 然后在application.yml或者(application.properties)中加入配置
application.yml:
mybatis-plus:
mapper-locations: classpath:com/atguigu/eduservice/mapper/xml/*.xml
另外一个也是一样的哦!!!