Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/myba

用idea使用mybatis时

 <mappers>
        <mapper resource="com/mybatis/mapper/UserMapper.xml"></mapper>
    </mappers>

遇到吐下错误时

 Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/mybatis/mapper/UserMapper.xml

如果文件路径没问题,可能是maven工程的问题,只能在resources中读取到xml文件,需要在pom.xml文件加上以下

  <build>
        <resources>
            <!-- resources文件 -->
            <resource>
                <directory>src/main/java</directory>
                <!-- 引入映射文件 -->
                <includes>
                    <include>**/*.xml
                
            
        
    

你可能感兴趣的:(Java,java)