I am using a combination of @PropertySource and @ConfigurationProperties but I want to overwrite them with an external properties file

别说谁变了你拦得住时间么 提交于 2019-12-06 16:43:44

Have you looked into PropertySources?

@PropertySources({
    @PropertySource("classpath:abc.properties"),
    @PropertySource(value="file:abc.properties", ignoreResourceNotFound=true)
})

From their doc:

In cases where a given property key exists in more than one .properties file, the last @PropertySource annotation processed will 'win' and override.

Basically what you are saying here: load abc.properties from classpath, but also load abc.properties from this external location, just ignore the latter if it doesn't find it. It should override the properties you declared in the external file.

Haven't tested this, so hope it works out.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!