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