当我使用Maven在sqlMapConfig.xml文件代码中构建项目时,如下所示:
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper resource="com/rl/ecps/sqlMap/EbBrandMapper.xml"/>
<mapper resource="com/rl/ecps/sqlMap/EbItemMapper.xml"/>
</mappers>
</configuration>
Tomcat启动将报告错误如下:
Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/rl/ecps/sqlMap/EbItemMapper.xml
at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor.postProcessPropertyValues(AutowiredAnnotationBeanPostProcessor.java:288)
但是,当我配置如下时,Tomcat不会启动异常 如下:
<!DOCTYPE configuration
PUBLIC "-//mybatis.org//DTD Config 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-config.dtd">
<configuration>
<mappers>
<mapper resource="com/rl/ecps/sqlMap/EbBrandMapper.xml"/>
<!-- <mapper resource="com/rl/ecps/sqlMap/EbItemMapper.xml"/> -->
</mappers>
</configuration>
我查完官方文档后,我确定这个配置没问题。我不知道为什么错了?请告诉我。谢谢!
答案 0 :(得分:0)
IOException:找不到资源com / rl / ecps / sqlMap / EbItemMapper.xml
错误很明显。文件&#34; com / rl / ecps / sqlMap / EbItemMapper.xml&#34;找不到。检查你的路径。看起来你在&#34; com&#34;。
之前忘记了正斜杠使用&#34; /com/rl/ecps/sqlMap/EbItemMapper.xml"。