title: How to use YamlPropertiesFactoryBean to load YAML files using Spring Framework 4.1?
body: <p>I have a spring application that is currently using *.properties files and I want to have it using YAML files instead.</p>
  
  <p>I found the class <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/config/YamlPropertiesFactoryBean.html">YamlPropertiesFactoryBean</a> that seems to be capable of doing what I need. </p>
  
  <p>My problem is that I'm not sure how to use this class in my Spring application (which is using annotation based configuration).
  It seems I should configure it in the <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.html">PropertySourcesPlaceholderConfigurer</a> with the  <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/beans/factory/config/PlaceholderConfigurerSupport.html#setBeanFactory-org.springframework.beans.factory.BeanFactory-">setBeanFactory</a> method.</p>
  
  <p>Previously I was loading property files using <a href="http://docs.spring.io/spring/docs/current/javadoc-api/org/springframework/context/annotation/PropertySource.html">@PropertySource</a> as follows:</p>
  
  <pre><code>@Configuration
  @PropertySource("classpath:/default.properties")
  public class PropertiesConfig {
  
      @Bean
      public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
          return new PropertySourcesPlaceholderConfigurer();
      }
  }
  </code></pre>
  
  <p>How can I enable the YamlPropertiesFactoryBean in the PropertySourcesPlaceholderConfigurer so that I can load YAML files directly? 
  Or is there another way of doing this?</p>
  
  <p>Thanks.</p>
  
  <p>My application is using annotation based config and I'm using Spring Framework 4.1.4. 
  I found some information but it always pointed me to Spring Boot, like <a href="http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html">this one</a>.</p>