class path resource [com/cn/bonc/mapping/] cannot be resolved to URL because it does not exist

<span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">Caused by: </span><span style="font-family: Arial, Helvetica, sans-serif;  background-color: rgb(255, 255, 255);"><u><span style="color:rgb(0,0,128)">java.lang.IllegalArgumentException</span></u></span><span style="font-family: Arial, Helvetica, sans-serif; background-color: rgb(255, 255, 255);">: Could not resolve resource location pattern [classpath:/com/cn/bonc/mapping/*.xml]: class path resource [com/cn/bonc/mapping/] cannot be resolved to URL because it does not exist</span>

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)

... 45 more

 

首先要理解配置文件中:classpath的含义?

<property name="mapperLocations" value="classpath:com/cn/bonc/mapping/*.xml"></property>

 

编写的java源文件经过编译后生成class文件,需要指定目录存放这些文件。web程序默认都在web-info/classes目录下存放我们的java编译后的文件。
但是web-info目录下还有各种jar包和配置文件呢,确切说web-info根目录才是程序运行时classpath

 

 

 

 

打开深入,突然发现, 确实没有mapping文件??????

 

原来是编译后, 没有生成相应的文件:

处理:

 在pom里面添加:

<build>
  
    <finalName>filecontrol</finalName>
     <resources>
    <resource>
        <directory>src/main/resources</directory> 
        <includes>
        <include>**/*.properties</include>
        <include>**/*.xml</include>
        <include>**/*.tld</include>
        </includes>       
        <filtering>false</filtering>
    </resource>
    <resource>
        <directory>src/main/java</directory>
        <excludes>
            <exclude>**/*.java</exclude>
        </excludes>
    </resource>
	</resources>
  </build>


  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 13
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值