title: Getting lists from Spring Boot configuration
body: <p>My Spring Boot application doesn't seem to be recognising lists in my configuration file (application.yml). Below is roughly what I'm trying to do.</p>
  
  <p><strong>Java Code</strong>:</p>
  
  <pre><code>@Autowired
  private Environment environment;
  
  public class Config{
    public Config(){
    }
  
    public List&lt;String&gt; getDateFields(){
      return environment.getProperty("dates.fields", List.class);
    }
  }
  </code></pre>
  
  <p><strong>application.yml</strong>:</p>
  
  <pre><code>dates:
    fields:
    - date
    - creationDate
  </code></pre>
  
  <p><code>getDateFields</code> returns null above. However, if I use the following...</p>
  
  <p><strong>application.yml</strong>:</p>
  
  <pre><code>dates:
    fields: creationDate
  </code></pre>
  
  <p>...it works fine and returns it as a list (albeit a single valued one). Why can't I get the list from my application.yml file? I tried checking whether <code>environment</code> even contained <code>dates.fields</code>, and <code>environment.containsProperty("dates.fields")</code> returns <code>false</code> when using the list version.</p>