关于Mapper文件找不到的问题: Could not find resource com/xx/dao/UserMapper.xml
-
问题:
-
Caused by: java.io.IOException: Could not find resource com/ljxdemo/dao/UserMapper.xml
-
问题原因1:maven过滤资源导致;
-
问题原因2:mapper.xml的包路径或者名字写错;(因为编译后)
-
-
解决方案:
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
-
笔记:
-
一定要注意Mapper.xml的包路径问题【重要】;
-
target
-
Mapper.xml被加载后,会放在和Mapper接口同级目录;
-

浙公网安备 33010602011771号