报错:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.atguigu.imperial.court.mapper.EmpMapper.selectByExample
原理:maven默认情况下,只会将java文件进行编译打包,扫描不到EmpMapper.xml文件。
[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-I7JCO0Gs-1692860908448)(C:\Users\cuihe\AppData\Roaming\Typora\typora-user-images\image-20230824150312500.png)]
解决思路:
1、application-dev.yml 文件中加上xml文件扫描路径:
mybatis-plus:
mapper-locations: classpath*:/com/atguigu/*/mapper/xml/*.xml
2、在pom.xml中配置resource扫描包
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.yml</include>
<include>**/*.properties</include>
<include>**/*.xml</include>
<include>**/*.png</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
</build>
</resources>
</build>