Mybatis解决Cause: java.io.IOException: Could not find resource XXX/XXX.xml问题

前几天在练习Mybatis发生的一个错误,记录一下

1.错误如下:
Error parsingSQLMapperConfiguration.Cause:java.io.IOException: Could not find resource dao/StudentDao.xml

2.项目结构:
Mybatis解决Cause: java.io.IOException: Could not find resource XXX/XXX.xml问题_第1张图片
3.错误分析:
这个是Could not find resource com/xxx/xxx/Xxx.xml的错误。我使用的是idea软件,在idea中是不会编译src的java目录的xml文件,所以在Mybatis的配置文件中找不到xml文件!(也有可能是Maven构建项目的问题)。

4.解决:
直接在pom.xml文件中,加入下面的代码就可以了




  
    src/main/java
    
    
      **/*.xml
    
  



5.加入上面代码,问题解决了,这就很开心
Mybatis解决Cause: java.io.IOException: Could not find resource XXX/XXX.xml问题_第2张图片

你可能感兴趣的:(Mybatis解决Cause: java.io.IOException: Could not find resource XXX/XXX.xml问题)