title: Loading multiple YAML files (using @ConfigurationProperties?)
body: <p>Using Spring Boot 1.3.0.RELEASE</p>
  
  <p>I have a couple of yaml files that describe several instances of a program. I now want to parse all those files into a <code>List&lt;Program&gt;</code> (Map, whatever), so I can later on search for the most appropriate instance for a given criteria in all the programs. </p>
  
  <p>I like the approach with <code>@ConfigurationProperties</code> a lot, and it works good enough for a single yaml-file, but I haven't found a way yet to read all files in a directory using that method.</p>
  
  <p>Current approach working for a single file:</p>
  
  <pre><code>programs/program1.yml
  
  name: Program 1
  minDays: 4
  maxDays: 6
  </code></pre>
  
  <p>can be read by</p>
  
  <pre><code>@Configuration
  @ConfigurationProperties(locations = "classpath:programs/program1.yml", ignoreUnknownFields = false)
  public class ProgramProperties {
  
  private Program test; //Program is a POJO with all the fields in the yml.
  //getters+setters
  </code></pre>
  
  <p>I tried changing the locations to an Array listing all of my files <code>locations = {"classpath:programs/program1.yml", "classpath:programs/program2.yml"}</code> as well as using <code>locations = "classpath:programs/*.yml"</code>, but that still only loads the first file (array-approach) or nothing at all (wildcard-approach).</p>
  
  <p>So, my question is, what is the best way in Spring Boot to load a bunch of yaml files in a classpath-directory and parse them into a (List of) POJO, so they can be autowired in a Controller? Do I need to use Snakeyaml directly, or is there an integrated mechanism that I just haven't found yet?</p>
  
  <p>EDIT:
  A working approach is doing it manually:</p>
  
  <pre><code>    private static final Yaml yaml = new Yaml(new Constructor(Program.class));
  private static final ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
  
  try {
          for (Resource resource : resolver.getResources("/programs/*.yml")) {
  
              Object data = yaml.load(resource.getInputStream());
  
              programList.add((Program) data);
          }
      }
      catch (IOException ioe) {
          logger.error("failed to load resource", ioe);
      }
  </code></pre>