Spring Boot how to set spring.config.location in application.properties for yaml
<p>I use spring boot 1.4.2 and now on try to set properties.</p>

<p>I have four cases about using <strong>.properties</strong> and <strong>.yml</strong> to external(inside resources) and local file system (outside project folder).</p>

<p>The <strong>.properties</strong> external (inside resource folder) works well both <strong>@Value(${property.name})</strong> and <strong>@PropertySource</strong> last one use value attribute can load from the file system like below.</p>

<pre><code>@Component
@PropertySource(value="file:C:\\properties\\application-dev.properties")
@PropertySource(value="file:C:\\properties\\application-test.properties")
public class ExternalProperties {
   // ...
}
</code></pre>

<p>But <strong>.yml</strong> isn't that works well under resource folder when the file name 'application.yml'</p>

<p>The .yml can be loaded by @ConfigurationProperties and need 'propdeps-plugin'</p>

<p>my .yml file</p>

<pre><code>environments:
    dev:
        url: http://dev.bar.com
        name: Developer Setup
    prod:
        url: http://foo.bar.com
        name: My Cool App
</code></pre>

<p>This code works well</p>

<pre><code>@Component
// external(inside resources)
@ConfigurationProperties(prefix="environments")
// outside project folder
@ConfigurationProperties(locations={"file:C:\\properties\\application.yml"}, prefix = "environments")
public class YamlProperties {

    private Map&lt;String, String&gt; dev = new HashMap&lt;&gt;();
    private Map&lt;String, String&gt; prod = new HashMap&lt;&gt;();

    public Map&lt;String, String&gt; getDev() {
        return this.dev;
    }

    public Map&lt;String, String&gt; getProd() {
        return this.prod;
    }
}
</code></pre>

<p>That code has problem of <strong>deprecated</strong> location attribute (I read many articles but can't figure out clearly) so I need find API doc and find <strong>'ConfigFileApplicationListener'</strong> from this <a href="http://docs.spring.io/spring-boot/docs/1.4.2.RELEASE/reference/htmlsingle/#common-application-properties" rel="noreferrer">section</a>.</p>

<pre><code># SPRING CONFIG - using environment property only (ConfigFileApplicationListener)
spring.config.location= # Config file locations.
spring.config.name=application # Config file name.
</code></pre>

<p>So write above property on application.properties like this.</p>

<pre><code>spring.config.location=file:C:\\properties\\application.yml
spring.config.name=application
</code></pre>

<p>and reloading the .yml property (I didn't try excute jar. I use the war and test through Controller)</p>

<pre><code>@Component
@ConfigurationProperties(prefix="environments")
public class YamlProperties {

     private Map&lt;String, String&gt; dev = new HashMap&lt;&gt;();
     private Map&lt;String, String&gt; prod = new HashMap&lt;&gt;();

     public Map&lt;String, String&gt; getDev() {
         return this.dev;
     }

     public Map&lt;String, String&gt; getProd() {
         return this.prod;
     }
}
</code></pre>

<p>This code didn't load the .yml from local file system C: drive but when add application.yml file in the resource folder then works well.</p>

<p>So how to set the <strong>spring.config.location</strong> for load .yml</p>

<p>And I want to know about why the location attribute works yet although deprecated since 1.4 ver.</p>

<p>and wondering how to use the ConfigFileApplicationListener I can't follow up the code it's hard to understand give some tip~!</p>

<blockquote>
  <p>EDIT:</p>
  
  <p>I miss understood about this that when the war start again and make
  context again using the local file system properties. This is not the
  collectly linked it but remain for future step.</p>
  
  <p>The tomcat restart than war deploy the new one so I have the file on
  local system it contain properties if I change this file's data that
  could be udated properties context when tomcat restart.</p>
  
  <p>Why I keep try this work that I use public github account and protect
  connect db info something else to. I get this stuff and go on next
  issue like git-encrpt, spring-cloude, nginx, docker. Thank you for any help really
  helpful.</p>
</blockquote>