我为 Commons Configuration 贡献了一个 PropertySource,它是 >=2.1 版本的一部分:org.apache.commons.configuration2.spring.ConfigurationPropertySource
例如在扩展的 PropertySourcesPlaceholderConfigurer 中使用它:
public class ApacheCommonsConfigPlaceholderConfigurer extends PropertySourcesPlaceholderConfigurer {
public ApacheCommonsConfigPlaceholderConfigurer(Configuration configuration) {
ConfigurationPropertySource apacheCommonsConfigPropertySource =
new ConfigurationPropertySource(configuration.getClass().getName(), configuration);
MutablePropertySources propertySources = new MutablePropertySources();
propertySources.addLast(apacheCommonsConfigPropertySource);
setPropertySources(propertySources);
}
}
如果解决了这个问题,代码会更简单:https ://jira.spring.io/browse/SPR-9631
另请参阅: http: //mail-archives.apache.org/mod_mbox/commons-user/201604.mbox/%3C44F558D5-0A26-4711-9658-39BD9052D751@capitalone.com%3E