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

转载自:https://www.cnblogs.com/canger/p/6007899.html

用IDEA新建了一个测试MyBatis工程,工程目录如下

Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource xxx_第1张图片
其中config是MyBatis的配置文件,内容如下




    
        
            
            
                
                
                
                
            
        
    

    
        
    

编译时提示错误 Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource com/shao/mapping/userMapper.xml

即找不到userMapper.xml这个Mapper文件,仔细查看了目录设置,并没有错误,在网上找了半天,终于发现原因:

idea不会编译src的java目录的xml文件

所以解决思路就是:将IDEA maven项目中src源代码下的xml等资源文件编译进classes文件夹

具体操作方法就是:配置maven的pom文件配置,在节点下添加代码:


        
            
                src/main/java
                
                    **/*.xml
                
            
        
    

你可能感兴趣的:(Error parsing SQL Mapper Configuration. Cause: java.io.IOException: Could not find resource xxx)