今天在做谷粒学院时,用到了编写Sql在Mapper的xml中进行多表查询.但是当项目启动后报了以下错误:

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice.._maven


这个错误是由Maven默认加载机制造成的

Maven加载时,把Java文件夹下的.java类型文件进行编译,对于其他类型文件,不会加载.

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice.._java_02

解决方式:
1.赋值xml文件到target目录中
2.把xml文件放到resources目录中
3.通过配置方式实现(推荐使用)

  • POM文件中添加配置
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
  • 配置文件中添加xml的路径
mybatis-plus:
mapper-locations: classpath:com/rg/eduservice/mapper/xml/*.xml

启动项目进行测试:—成功

org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.rg.eduservice.._bug_03