title: spring-boot properties not @Autowired
body: <p>I am trying to get a Spring-boot application going and I am not sure what I am doing wrong here.  I have a application.properties file at src/main/resources &amp; src/test/resources.   I have an @Bean for my ConfigurationSettings so that I can use them throughout my application:</p>
  
  <pre><code>@Component
  public class ConfigurationSettings {
  
  private String product;
  private String version;
  private String copyright;
  private String appName;
  private String appDescription;
  ... 
  // getters and setters
  
  }
  </code></pre>
  
  <p>Here is how I kick the application off:</p>
  
  <pre><code>@Configuration
  @EnableJpaRepositories
  @EnableAutoConfiguration
  @EnableConfigurationProperties
  @PropertySources(value = {@PropertySource("classpath:application.properties")})
  @ComponentScan(basePackages = "com.product")
  @EnableScheduling
  public class OFAC {
  
  public static void main(String[] args) {
      ApplicationContext ctx = SpringApplication.run( OFAC.class, args );        
  }
  </code></pre>
  
  <p>And here is my configuration class:</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackages = {"com.product"})
  @PropertySources(value = {@PropertySource("classpath:application.properties")})
  public class OFAConfiguration {
  
       @Autowired
       private Environment env;
  
       @Bean
       public ConfigurationSettings configurationSettings() {
           ConfigurationSettings configurationSettings = new ConfigurationSettings();
           configurationSettings.setAppDescription( env.getRequiredProperty("app.description" ) );
           configurationSettings.setAppName( env.getRequiredProperty( "app.name" ) );
           configurationSettings.setServerPort( env.getRequiredProperty( "server.port" ) );
           return configurationSettings;
      }
  </code></pre>
  
  <p>I am trying to use it in a controller:</p>
  
  <pre><code>@RestController
  public class AboutController {
  
     @Autowired
     private ConfigurationSettings configurationSettings;
  
     @RequestMapping(value = "/about", method = RequestMethod.GET)
     public About index() {
  
       String product = configurationSettings.getProduct();
       String version = configurationSettings.getVersion();
       String copyright = configurationSettings.getCopyright();
      return new About( product, version, copyright );
     }
  }
  </code></pre>
  
  <p>However, when step thru this, all the values of ConfigurationSettings are null.   I do have a test that successfully loads the values:</p>
  
  <pre><code>@RunWith(SpringJUnit4ClassRunner.class)
  @ContextConfiguration(classes = {OFAConfiguration.class})
  public class OFAConfigurationTest {
    @Autowired
    private Environment environment;
  
    @Autowired
    private ConfigurationSettings configurationSettings;
  
    @Test
    public void testConfigurationLoads() {
      assertNotNull(environment);
      Assert.assertNotNull(configurationSettings);
    }
  
    @Test
    public void testConfigurationSettingValues() {
       assertEquals("Product Name", configurationSettings.getProduct());
      assertEquals("0.0.1", configurationSettings.getVersion());
      assertEquals("2014 Product", configurationSettings.getCopyright());
   }
  </code></pre>
  
  <p>Can anyone see why the ConfigurationSettings are not being populated in my Controller?</p>