这是mybatis-config.xml:
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<environments default="development">
<environment id="development">
<transactionManager type="JDBC"/>
<dataSource type="POOLED">
<property name="driver" value="com.mysql.jdbc.Driver"/>
<property name="url"
value="jdbc:mysql://localhost:3306/jupan_mail?useUnicode=true&characterEncoding=UTF-8&"/>
<property name="username" value="root"/>
<property name="password" value="password"/>
</dataSource>
</environment>
</environments>
<mappers>
<mapper resource="com/salamander/backcal/mapping/MailChangeMapper.xml"/>
</mappers>
</configuration>
这是项目结构:
单元测试报错:
Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/salamander/backcal/dao/MailChangeMapper.xml
找到解決方案了(原因是: idea不會編譯src的java目錄的xml檔):
在pom.xml中加入節點:
參考:http://www.cnblogs.com/canger...
將非
java
文件移至resources
目錄中。com/salamander/backcal/dao/MailChangeMapper.xml
报错的路径是
dao
這個包下的。但是你貼的配置卻和報錯的路徑是不同的。
引人深思
活著配置一個類似的標籤,試試看。