1. 程式人生 > >報錯:BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:sprin

報錯:BeanDefinitionStoreException: Could not resolve bean definition resource pattern [classpath:sprin

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表標籤中選擇檔案型別