1. 程式人生 > >maven專案-載入不到spring檔案,BeanFactory not initialized or already closed

maven專案-載入不到spring檔案,BeanFactory not initialized or already closed

嚴重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener

org.springframework.beans.factory.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

嚴重: Exception sending context destroyed event to listener instance of class org.springframework.web.context.ContextLoaderListener
java.lang.IllegalStateException: BeanFactory not initialized or already closed - call ‘refresh’ before accessing beans via the ApplicationContext

這裡寫圖片描述

如果是maven專案 src / main / resources 目錄下的檔案路徑沒有問題才報錯的話,就在專案的pom工程下,編輯pom.xml

    <build>
        <!-- 預設原始碼和資原始檔目錄配置 -->  
        <sourceDirectory>src/main/java</sourceDirectory>  
        <resources>
            <resource>  
                <directory>src/main/resources</directory>  
            </resource> 
        </resources
>
</build>