在使用maven时出现的错误:
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com.laoli.dao.UserMapper.xml
解决方法:
-
首先查看是否在pom.xml中导入了build
<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>
这段代码主要解决资源无法导出的问题
- 如果添加完之后还是无效:
在mybatis-config.xml文件中将注册mapper的如下代码
<mappers>
<mapper resource="com.laoli.dao.UserMapper.xml"></mapper>
</mappers>
改为:
<mappers>
<mapper resource="com/laoli/dao/UserMapper.xml"></mapper>
</mappers>
即路径中的 “.” 改为"/"