title: Spring @Configuration file with PropertyPlaceholderConfigurer bean doesn't resolve @Value annotation
body: <p>I have following configuration file:</p>
  
  <pre><code>@Configuration
  public class PropertyPlaceholderConfigurerConfig {
  
      @Value("${property:defaultValue}")
      private String property;
  
      @Bean
      public static PropertyPlaceholderConfigurer ppc() throws IOException {
          PropertyPlaceholderConfigurer ppc = new PropertyPlaceholderConfigurer();
          ppc.setLocations(new ClassPathResource("properties/" + property + ".properties"));
          ppc.setIgnoreUnresolvablePlaceholders(true);
          return ppc;
      }
  }
  </code></pre>
  
  <p>I run my application with following VM option: </p>
  
  <pre><code>-Dproperty=propertyValue
  </code></pre>
  
  <p>So I'd like my application to load specific property file on startup. But for some reason at this stage <code>@Value</code> annotations are not processed and property is <code>null</code>. On the other hand if I have <code>PropertyPlaceholderConfigurer</code> configured via xml file - everything works perfectly as expected. Xml file example:</p>
  
  <pre><code>&lt;bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"&gt;
      &lt;property name="ignoreResourceNotFound" value="true"/&gt;
      &lt;property name="location"&gt;
          &lt;value&gt;classpath:properties/${property:defaultValue}.properties&lt;/value&gt;
      &lt;/property&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>If I try to to inject property value in another Spring configuration file - it is properly injected. If I move my <code>PropertyPlaceholderConfigurer</code> bean creation to that configuration file - field value is null again. </p>
  
  <p>As workaround, I use this line of code:</p>
  
  <pre><code>System.getProperties().getProperty("property", "defaultValue")
  </code></pre>
  
  <p>Which is also works, but I'd like to know why such behavior is occurs and maybe it is possible to rewrite it in other way but without xml?</p>