idea+maven项目
啊~竟然在同一个错误上栽倒两次,做一这次下了好好写报错记录的原因
报错如下:
BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:spring/applicationContext-*.xml]; nested exception is java.io.FileNotFoundException: class path resource [spring/] cannot be resolved to URL because it does not exist
不难看出上面所描述的是在找不到Spring文件夹下面的applicationContextXX文件
打开target目录下的classes发现,本该被复制到下面的配置文件并不在。原因是idea默认只拷贝java文件夹下面的东西,所以在pom文件下加上如下代码
<resources>
<resource>
<directory>src/main/resource</directory>
<includes>
<include>**/*.properties</include>
<include>**/*.xml</include>
</includes>
<filtering>false</filtering>
</resource>
</resources>
可以在directory 标签中加入文件目录
在include表标签中选择文件类型