报错:classpath resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist

参考: http://www.jianshu.com/p/800fe918cc7a
ssm整合的时候报错:

Caused by: java.lang.IllegalArgumentException: Could not resolve resource location pattern [classpath:com/qinkangdeid/mapping/*.xml]: class path resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist

at org.springframework.core.io.support.ResourceArrayPropertyEditor.setAsText(ResourceArrayPropertyEditor.java:140)
    at org.springframework.beans.TypeConverterDelegate.doConvertTextValue(TypeConverterDelegate.java:430)
    at org.springframework.beans.TypeConverterDelegate.doConvertValue(TypeConverterDelegate.java:403)
    at org.springframework.beans.TypeConverterDelegate.convertIfNecessary(TypeConverterDelegate.java:181)
    at org.springframework.beans.BeanWrapperImpl.convertIfNecessary(BeanWrapperImpl.java:459)
    ... 72 more


解决:
在配置文件下 扫描不到 xml文件:
原来的文件:


    
    
    

修改classpath 为 classpath*


    
    
    

运行测试:又出现另外的报错:
org.apache.ibatis.binding.BindingException: Invalid bound statement (not found): com.qinkangdeid.dao.UserMapper.selectByPrimaryKey
报错:classpath resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist_第1张图片

解决:
war包里面缺少Mapper对应的xml文件,也就是没有把xml文件打包进去。解决办法是,在pom.xml文件中的build标签中添加如下代码,显示的强制将xml文件打到war包中:

报错:classpath resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist_第2张图片

 
        <resources>
            <resource>
                <directory>src/main/javadirectory>
                <includes>
                    <include>**/*.xmlinclude>
                includes>
                <filtering>falsefiltering>
            resource>
        resources>

重新测试,成功:
报错:classpath resource [com/qinkangdeid/mapping/] cannot be resolved to URL because it does not exist_第3张图片

你可能感兴趣的:(问题解决)