【Bug解决】Could not find resource com/kuang/mapper/Mapper.xml

2022-06-14 11:46:51 浏览数 (1)

在使用mybatis时,遇到这个问题:

代码语言:javascript复制
Could not find resource com/kuang/mapper/Mapper.xml

解决方案: 1.首先检查mapper文件中,resultType是否为实体类对象

代码语言:javascript复制
<mapper namespace="com.kuang.mapper.UserMapper">
    <select id="selectUser" resultType="com.kuang.pojo.User">
        select * from user
    </select>
</mapper>

ctrl 左键能够跳转说明没问题。

2.Maven静态资源过滤问题 在配置文件pom.xml文件中添加

代码语言:javascript复制
    <build>
        <resources>
            <resource>
                <directory>src/main/java</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
            <resource>
                <directory>src/main/resources</directory>
                <includes>
                    <include>**/*.properties</include>
                    <include>**/*.xml</include>
                </includes>
                <filtering>false</filtering>
            </resource>
        </resources>
    </build>

重新刷新Maven,问题解决。

0 人点赞