title: Spring @Bean instantiation depending on @Value annotation
body: <p>I am using Spring Boot and having trouble initializing one of my beans correctly. The definition goes like this :</p>
  
  <pre><code>@Configuration
  public class BeanConfiguration  {
      @Value("${foo.config}")
      private String fooConfig;
  
      @Bean
      public Foo getFoo(){
          Foo foo = new Foo();
          foo.setConfig(fooConfig);
          return foo;
      }
  }
  </code></pre>
  
  <p>Then, when using the foo bean autowired the foo.getConfig() is null. At the time the bean Foo is created, Spring has not yet populated the fooConfig value from the application.properties file.</p>
  
  <p>What would be the proper way to instantiate the bean? Thanks!</p>