首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

满载spring中的PropertyPlaceholderConfigurer,获得加载的属性

2012-09-14 
重载spring中的PropertyPlaceholderConfigurer,获得加载的属性今天又重载了PropertyPlaceholderConfigurer

重载spring中的PropertyPlaceholderConfigurer,获得加载的属性

今天又重载了PropertyPlaceholderConfigurer,为了把properties中的值拿出来,我重新了processProperties()方法。

获得属性值:

spring 2.x:parseStringValue(props.getProperty(keyStr), props,new HashSet());

spring 3.x: resolvePlaceholder(keyStr, props);

parseStringValue 方法已过时。。。

1 楼 yangshiman 2012-02-10   protected void processProperties(
ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess,props);
for (Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
String propertyName = (String) propertyNames.nextElement();
String propertyValue = props.getProperty(propertyName);
String convertedValue = convertProperty(propertyName, propertyValue);
PropertiesPool.load(propertyName, convertedValue);
}
} 2 楼 qq123zhz 2012-02-10   yangshiman 写道protected void processProperties(
ConfigurableListableBeanFactory beanFactoryToProcess,
Properties props) throws BeansException {
super.processProperties(beanFactoryToProcess,props);
for (Enumeration propertyNames = props.propertyNames(); propertyNames.hasMoreElements();) {
String propertyName = (String) propertyNames.nextElement();
String propertyValue = props.getProperty(propertyName);
String convertedValue = convertProperty(propertyName, propertyValue);
PropertiesPool.load(propertyName, convertedValue);
}
}

你是直接遍历了

热点排行