报错:
### The error may exist in com/cth/dao/UserImpl.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/cth/dao/UserImpl.xml
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:30)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:80)
at org.apache.ibatis.session.SqlSessionFactoryBuilder.build(SqlSessionFactoryBuilder.java:64)
at com.cth.domain.User.main(User.java:17)
……
原因
因为com/cth/dao/
下的UserImpl.xml
文件没有被编译到target/classes
目录下对应的目录中,不信你可以在项目中的target/classes
目录下找一找,绝对是找不到的
解决方法:
-
方法一:将
com/cth/dao
目录下的文件放到resource
目录下 -
方法二:在pom文件中添加以下代码
<build> <resources> <resource> <directory>src/main/java</directory> <includes> <include>**/*.properties</include> <include>**/*.xml</include> </includes> <filtering>false</filtering> </resource> </resources> </build>