I'm currently trying to convert a mostly-Java-with-some-XML Spring 3.0.6 configuration to a Java-only configuration with Spring 3.1.0.RC1.

In my old XML context, I use a property placeholder
Code:
  <context:property-placeholder location="file:${MY_CONFIG}"/>
where MY_CONFIG is an environment variable pointing to a properties file.

What is the equivalent of this in a Java configuration?

Here is what currently works for me:

Code:
    @Bean
    public static PropertySourcesPlaceholderConfigurer propertyConfigurer() {
        PropertySourcesPlaceholderConfigurer bean = new PropertySourcesPlaceholderConfigurer();        
        bean.setLocation(new FileSystemResource(System.getenv("MY_CONFIG")));
        return bean;
    }
But I'm not sure if this is the best practice. In particular, the explicit lookup of the environment variable somehow doesn't feel right...

Best regards,
Harald