我有配置文件位於除我的jar文件以外的其他目錄中的問題。@PropertySource無法打開,因爲它不存在
我使用@PropertySource
來加載屬性。
@PropertySource(ignoreResourceNotFound = true, value = "${ext.properties.dir:classpath:}/properties.properties")
我嘗試使用下面的命令來運行的jar:
java -jar import-0.0.1-SNAPSHOT.jar -Dext.properties.dir=file:/C:\Users\Admin\Desktop\
以下錯誤普林在日誌:屬性位置
屬性位置 [$ {ext.properties.dir: classpath:}/properties.properties]無法解析: 無法打開類路徑資源[properties.properties],因爲它不存在 不存在
我該如何解決這個錯誤?
這可能會幫助你 - https://stackoverflow.com/questions/33184807/override-properties-file-in-spring-webapp-at-runtime – Arpit
@Arpit,我做了與答案中相同的配置,但我得到了'不能打開,因爲它不存在' –
你使用的是'spring mvc'還是'spring boot'? – elmigue017