I have specified an external properties file to a Spring Boot app by setting spring.config.additional-location
in the SpringApplicationBuilder
.
new SpringApplicationBuilder(MyApplication)
.properties(['spring.config.additional-location': myExternalProperties])
.run(myArgs)
This works insofar as it allows me to override properties in the application.properties
file using myExternalProperties
.
However, myExternalProperties
are in turn overridden by any profile-specific properties, e.g. application-myProfile.properties
.
I understand this to be consistent with Spring's prioritization of Externalized Configuration, but I want myExternalProperties
to override even profile-specific properties.
How can I achieve that order of priority?
I do not control the file name or location of myExternalProperties
. This variable is a System property that is preset in the environment.
I have been looking at Profile-specific Properties and in particular this quote.
If you have specified any files in
spring.config.location
, profile-specific variants of those files are not considered. Use directories inspring.config.location
if you want to also use profile-specific properties.
I assume this note applies equally to spring.config.additional-location
, but without control over the property file name or location I don't think that helps me.