Could not find resource——mybatis 找不到映射器xml文件

今天用IDEA写Mybatis的时候,测试报了如图所示的错,恶心死我了,后来解决了,总结一下,防止下回跳坑,当然,也是做一个分享,如果有朋友遇到这个错,希望有所帮助

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

 我先直接改错,后面分析:

 

 

<resources>
      <resource>
        <directory>src/main/Java</directory>
        <excludes>
          <exclude>**/*.java</exclude>
        </excludes>
      </resource>
      <resource>
        <directory>src/main/resources</directory>
        <includes>
          <include>**/*.* </include>
        </includes>
      </resource>
    </resources>

  

 

 

错误分析:

 

 idea编译Java程序时默认只编译resources目录下的mapper文件,所以如果你的mapper文件放在非resources目录下那么要在pom文件下增加一个配置,否则无法自动映射对应的mapper文件。

 

posted @ 2019-08-08 16:33  泰斗贤若如  阅读(2009)  评论(0编辑  收藏  举报