3
如果我有一個PropertyPlaceholderConfigurer
通過XML文件傳入,是否可以讓我的Spring @Configuration
使用它作爲它處理的所有bean的屬性來源?屬性與Spring @Configuration
@Configuration
@ComponentScan(value = { "x.y.z })
@ImportResource({ "classpath:remote-properties/applicationContext.xml",})
public class CoreConfiguration implements TransactionManagementConfigurer {
@Resource(name = "com.c.h.c.PropertyPlaceholderConfigurer")
public PropertyPlaceholderConfigurer pp;
@Bean
public PropertyPlaceholderConfigurer propertiesFactoryBean() {
return pp;
}
}
通過上述,它從來沒有擊中我的pp
斷點。如果我刪除@Bean
和該方法,我可以驗證pp
已填充。那麼我怎麼才能使用配置註冊呢?
您是否瀏覽過http://forum.springsource.org/showthread.php?107194-PropertyPlaceholderConfigurer-and-javconfig –
@Rob我無法直接使用屬性文件。我必須從該應用內容中使用PropertyPlaceholderConfigurer bean,或者加載具有第二個屬性文件的url的屬性文件,然後加載該屬性文件。我知道這聽起來很荒謬,但這是我解決多個環境問題的團隊。 – AHungerArtist
@Rob更重要的是,我不僅需要'@Configuration'類本身的屬性,還可以在'@ComponentScan'對'@Service'註釋類執行魔術時使用它們(所以'@Value'註釋將會得到正確填充)。 – AHungerArtist