title: Spring Boot: Load @Value from YAML file
body: <p>I need to load a property from a <code>.yml</code> file, which contains the path to a folder where the application can read files from.</p>
  <p>I'm using the following code to inject the property:</p>
  <pre><code>@Value(&quot;${files.upload.baseDir}&quot;)
  private String pathToFileFolder;
  </code></pre>
  <p>The <code>.yml</code> file for development is located under <code>src/main/resources/config/application.yml</code>, im running the application with the following command in production, to override the development settings:</p>
  <pre><code>java -jar app.jar --spring.config.location=/path/to/application-production.yml
  </code></pre>
  <p>The Spring Boot documentation says:</p>
  <blockquote>
  <p>SpringApplication will load properties from application.properties files in the following locations and add them to the Spring Environment:</p>
  <ol>
  <li><p>A /config subdirectory of the current directory.</p>
  </li>
  <li><p>The current directory</p>
  </li>
  <li><p>A classpath /config package</p>
  </li>
  <li><p>The classpath root</p>
  </li>
  </ol>
  </blockquote>
  <p>As well as:</p>
  <blockquote>
  <p>You can also use YAML ('.yml') files as an alternative to '.properties'.</p>
  </blockquote>
  <p>The <code>.yml</code> file contains:</p>
  <pre><code>{...}
  files:
        upload:
          baseDir: /Users/Thomas/Code/IdeaProjects/project1/files
  {...}
  </code></pre>
  <p>And my <code>Application</code> class is annotated with:</p>
  <pre><code>@SpringBootApplication
  @EnableCaching
  </code></pre>
  <p>When I run the application, i get an exception:</p>
  <pre><code>Caused by: java.lang.IllegalArgumentException: Could not resolve placeholder 'files.upload.baseDir' in string value &quot;${files.upload.baseDir}&quot;
  </code></pre>
  <p>Do I have to use the <code>YamlPropertySourceLoader</code> class or add a special annotation to enable the support for <code>.yml</code> in Spring Boot?</p>
  <p>Edit:
  The <code>.yml</code> file contains some other properties, which get successfully loaded by Spring Boot like <code>dataSource.XXX</code>or <code>hibernate.XXX</code>.</p>