title: Using placeholders in Annotations on Spring Java Configurations
body: <p>I'm a little bit lost in Spring's Property Replacement mechanism. Lets say I have this Java Config</p>
  
  <pre><code>@Configuration
  @ComponentScan(basePackageClasses = Application.class)
  @PropertySources({
      @PropertySource("classpath:/config/default.properties")
  })
  public class ApplicationConfig {
  
  @Bean
  public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
      PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
      return pspc;
  }
  </code></pre>
  
  <p>Now I want to add a Spring-Data Annotation <code>@EnableMongoRepositories</code> and define a custom basepackage for scanning, using a custom placeholder like follows 
  <code>@EnableMongoRepositories("${my.custom.repobasepackage}")</code>. The Placeholder is defined in my default.properties.</p>
  
  <p>However, this property cannot be resolved here. When diving deeper into Spring's property replacement, I can see that it tries to resolve the property, so it is possible to do so. </p>
  
  <p>However, the underlying <code>Environment</code> class which is used to replace the placeholder does not know about my PropertyPlaceholderConfigurer, but only know about my SystemProperties and my VM-Props. :-(</p>
  
  <p>I can see that in org.springframework.context.annotation.ClassPathBeanDefinitionScanner#getOrCreateEnvironment.java#339 (<strong>I'm using Spring 4.0.1</strong>) my "PropertyPlaceholder" is already in place, so its not a question of ordering in initialization, but is not used, because the used BeanDefinitionRegistry does not implement the Interface <code>EnvironmentCapable</code>. Here, my understanding of the Spring App-Context Bootstrapping is at the end. </p>
  
  <p>Can anybody help me out here? Is there a BeanDefinitionRegistry out there which is capable of providing the <code>Environment</code> Instance which uses my Property Placeholder?</p>
  
  <p>Any help is highly appreciated!! I got cookies for you! :-)) </p>
  
  <p>Cheers, Stefan</p>