我有配置文件位于除我的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