title: Spring Boot configuration behaviour with @ConfigurationProperties and Command Line arguments
body: <p>I seem to be having some funny behaviour with Spring boot on yaml property files im trying to load.</p>
  
  <p>I have a Settings bean that is setup as follows :</p>
  
  <pre><code>@ConfigurationProperties(location = 'config.yml', prefix='settings')
  public class Settings {
      private String path;
      ...
  }
  </code></pre>
  
  <p>I've explicitly told spring to look in the config.yml file for property values to bind to the Settings bean.  This looks like this:</p>
  
  <pre><code>settings:
     path: /yaml_path
  </code></pre>
  
  <p>This works well, however, I don't seem to be able to override these values from the command line i.e.</p>
  
  <pre><code>java -jar my.jar --settings.path=test
  </code></pre>
  
  <p>The value that is bound to the settings bean is still /yaml_path but would've expected that the --settings.path=test would override the settings in the yaml.</p>
  
  <p>Interestingly, I've noticed that if i take comment out the path setting from the yaml file, the commandline argument value of test comes through.  </p>
  
  <p>Additionally, I've also noticed that if i change my config file from config.yml to application.yml and remove the 'location' attribute from the configuration properties file this gives me the desired desired behaviour, but means that I can't have multiple application.yml files in the classpath as it breaks my multi module application which has configuration files throughout.</p>
  
  <p>Ideal world I would like be able to have modules read configuration from yaml files that contain safe values for that module (i.e. module.yml) and be able to override these values from the commandline if needed.  Has anyone figured out how to get commandline arguments passed into the beans this way?</p>
  
  <p>I have created a project on git hub to show case the issue</p>
  
  <p><a href="https://github.com/vcetinick/spring-boot-yaml-test" rel="nofollow">https://github.com/vcetinick/spring-boot-yaml-test</a></p>
  
  <p>Running the application displays logging information about what settings are applied. i.e.</p>
  
  <blockquote>
    <p>java -jar spring-boot-yaml-test-0.0.1-SNAPSHOT.jar --config.path=/test</p>
  </blockquote>
  
  <p>should override the settings, however, the default /var/tmp is displayed</p>
  
  <p>additionally, when using the application.yml configuration </p>
  
  <blockquote>
    <p>java -jar spring-boot-yaml-test-0.0.1-SNAPSHOT.jar --app.path=/test</p>
  </blockquote>
  
  <p>seems to behave as expected where the command line argument overrides the value but only works because its value is defined in the application.yml file.</p>