在idea中mybatis错误(1)

时间:2024-07-07 15:36:02
错误提示为:

### Error building SqlSession.
### The error may exist in cn/qd/mybatis/map/productMapper.xml
### Cause: org.apache.ibatis.builder.BuilderException: Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource cn/qd/mybatis/map/productMapper.xml

问题:在全局配置文件Configure.xml

<mappers>
<mapper resource="cn/qd/mybatis/map/productMapper.xml"/>
</mappers>
无法找到资源的路径,在idea中貌似无法识别productMapper.xml

问题解决:既然找不到.xml文件,那么就在maven编译时将.xml文件放进去。即:在pom.xml文件的<build>标签中,加入
<resources>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources> 原文出自:http://blog.****.net/witsmakemen/article/details/46913425