错误提示信息;
Caused by: java.io.IOException: Could not find resource org/example/mapper/Mapper.xml
at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:114)
at org.apache.ibatis.io.Resources.getResourceAsStream(Resources.java:100)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.mapperElement(XMLConfigBuilder.java:371)
at org.apache.ibatis.builder.xml.XMLConfigBuilder.parseConfiguration(XMLConfigBuilder.java:119)
... 5 more
这个错误是找不到Mapper.xml文件
1、配置文件和类都没问题
2、这个是我用Idea的maven项目时出现的一个bug
3、在网上查询的时候发现Idea中的src/java文件不支持xml
解决办法:
在maven中pom.xm文件中添加
<build>
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</build>