报错原因:
找不到Mapper.xml,原因是maven工程一般把xml文件放在resources目录下,而我们是把xml文件放在java目录下。由于maven约定大于配置,导致我们写的配置文件无法被导出或者生效。
解决方案:
在pom.xml中增加以下配置,放在<dependencies></dependencies>
外面才可以生效
<!--在build中配置resources,来防止我们资源导出失败的问题-->
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>