[idea] Maven項目 配置文件放在resources標記的目錄下 卻沒有打包進target文件

錯誤代碼:

嚴重: StandardWrapper.Throwable
org.springframework.beans.factory.BeanDefinitionStoreException: IOException parsing XML document from class path resource [springmvc.xml]; nested exception is java.io.FileNotFoundException: class path resource [springmvc.xml] cannot be opened because it does not exist

問題描述:

無法啓動tomcat,檢查target目錄發現存放在resources標記目錄下的*.xml配置文件沒有被打包進target目錄.

錯誤原因:

在pom文件中配置了其他位置的資源拷貝插件,漏過了resource文件

解決方法:

在pom.xml文件中(無論是當前項目的pom.xml還是父項目的pom.xml文件都有效)增加標籤

<build>
	<resources>
      <resource>
        <directory>src/main/resource(資源目錄)</directory>
        <includes>
          <include>**/*.xml</include>
          <include>**/*.properties</include>
        </includes>
      </resource>
    </resources>
</build>

(build標籤已存在就把部分加到已存在的build標籤中)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章