title: spring boot read properties from yml file
body: <p>I have a spring boot application where properties have to be read from a yaml file.</p>
  
  <p>code:</p>
  
  <pre><code>@Component
  @PropertySource("classpath:application.yml")
  public class ResourceProvider {
  
      @Autowire
      private Environment env;
  
      public String getValue(String key) {
          return env.getProperty("app.max.size");
      }
  }
  </code></pre>
  
  <p>yaml file</p>
  
  <pre><code>app:
    max:
      size: 10
  </code></pre>
  
  <p>When I try this it doesn't work. I get value for <code>app.max.size</code> as null. For <code>size</code> I get the value as 10.</p>
  
  <p>When I use application.properties. I am able to get the desired result. 
  Am I doing anything incorrectly?</p>
  
  <p>application.properties</p>
  
  <pre><code> app.max.size=10
  </code></pre>