title: Including profiles with spring.profiles.include seems to override instead of include
body: <p>I'm trying to partition configuration properties for several Spring Boot applications. I'm using Spring Boot 1.1.6, and our configuration properties are expressed in YAML in the usual application.yml style. I've created various profiles for common base parameters, common DB parameters, etc. I was trying to use the include feature mentioned in the Spring Boot reference docs, but it seems to work as an override and not an include. I.e. exactly the opposite of what I want. Given the following content in application.yml, I would have expected the property <strong>name</strong> to have the value <strong>bar</strong> when the <strong>bar</strong> profile is active, but instead it gets set to <strong>foo</strong> (from the included profile). I thought the notion of including meant that it was loaded first, and any identically named properties set in the new profile would override those from the included profile. Kind of like if a subclass is shadowing a field from the superclass, any instance of the subclass would reflect the shadowed value. Here's the file:</p>
  
  <pre><code>spring:
    profiles: foo
  name: foo
  
  --- # New YAML doc starts here
  
  spring:
    profiles: 
      include: foo
    profiles: bar
  name: bar
  </code></pre>
  
  <p>If I run this in a test case with the "bar" profile explicitly activated, the <strong>name</strong> property will still be foo:</p>
  
  <pre><code>SpringApplicationBuilder builder = new SpringApplicationBuilder(Application.class);
  SpringApplication app = builder.application();
  builder.profiles("bar");
  ConfigurableApplicationContext ctxt = app.run();
  String name = ctxt.getEnvironment().getProperty("name"); // Is always "foo" much to my surprise
  </code></pre>
  
  <p>However, if I comment out the include:</p>
  
  <pre><code>spring: 
  profiles: bar
  #  profiles: 
  #    include: foo
  </code></pre>
  
  <p>and activate the two profiles explicitly in my code:</p>
  
  <pre><code>builder.profiles("foo", "bar");
  </code></pre>
  
  <p>Then it works as I would expect, and the <strong>name</strong> property is set to <strong>bar</strong>. The main reason I would rather handle the includes in the YAML files is that it's less impact on my actual code, and I can manage all profile inclusion in one place. With the other approach, I'd have to search for profile strings and possible @Profile annotations in my entire project if I were to ever rename the profiles. That's definitely more error prone. I think a more flexible solution would be to explicitly be able to express whether or not the included profile overrides the sub profile values or not. Maybe something like:</p>
  
  <pre><code>spring:
    profiles: bar
    profiles:
      include: foo
        override: false
  </code></pre>
  
  <p>Maybe I'm just missing something here. Is there a better way of doing this? Thanks. </p>