Spring boot supports external configurations with the property --spring.config.location
If can point on an actual file, a folder or any combination of those.
The values in these properties files will override the values from the internal configuration locations.
Make sure you've read the relevant chapter of documention
Update:
as I've commented it's impossible to "suppress" an external configuration.
However, As one of the workaround, you can consider implementing an EnvironmentPostProcessor that will dynamically add profiles.
It runs after the environment is available but before spring actually processes its beans; in a nutshell, it provides a way to customize your configuration.
So this could rely on the following assumptions:
an external file is called "application-external.properties"
the application is always started with --spring.config.locations=<path_to_external_folder>
in addition to the above specify the profile:
--spring.profiles.active=local
This will load application.properties
and application-local.properties
available internally but won't touch the external file unless in the post processor you add something like (a pseudo code):
if(! getActiveProfiles().contains("local")) {
addProfile("external");
}
You can read about environment post processors Here