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

来源:互联网 发布:淘宝没有品牌授权 编辑:程序博客网 时间:2024/06/16 06:58

<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>


0 0
原创粉丝点击