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