1
创建FactoryBeany以从Zookeeper加载属性。Spring FactoryBean作为PropertySourcesPlaceholderConfigurer的参考
public class ZkPropertiesFactoryBean extends AbstractFactoryBean<Properties> {..}
在使用XML配置,可以如下
<bean id="zkProperties" class="test.ZkPropertiesFactoryBean"/>
<context:property-placeholder properties-ref="zkProperties"/>
我想XML配置转换成Java的配置,使用PropertySourcesPlaceholderConfigurer
@Bean
public static PropertySourcesPlaceholderConfigurer loadProperties() throws Exception {
PropertySourcesPlaceholderConfigurer prop = new PropertySourcesPlaceholderConfigurer();
prop.setIgnoreUnresolvablePlaceholders(true);
return prop;
}
什么是指豆相当于properties-ref
?我无法找到任何参考。