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表标簽中選擇檔案類型