MyBatis项目报错java.io.IOException: Could not find resource mapping/UserMapper.xml

问题描述:

报错如图下:Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource cn/dao/UserMapper.xml

 

解决方法:

1.首先看一下你的UserMapper.xml文件是不是放在src目录下,如果是那么报错的原因就是:maven是不会去编译src目录下的xml文件

 

2.需要在项目的pom.xml文件中添加这一段代码即可。

<!--在build中配置resouces,来防止资源导出失败问题-->
        <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>

 

已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页