PropertyPlaceholderConfigurer

@Service("propertyPlaceholder")publicclassPropertyPlaceholderextendsPropertyPlaceholderConfigurer{privatestaticMap<String,String>propertyMap;@OverrideprotectedvoidprocessProperties(ConfigurableListableBeanFactorybeanFactoryToProcess,Propertiesprops)throwsBeansException{super.processProperties(beanFactoryToProcess,props);propertyMap=newHashMap<String,String>();for(Objectkey:props.keySet()){StringkeyStr=key.toString();Stringvalue=props.getProperty(keyStr);propertyMap.put(keyStr,value);}}//staticmethodforaccessingcontextpropertiespublicObjectgetProperty(Stringname){returnpropertyMap.get(name);}}

xml

<beanclass="com.lxzl.config.PropertyPlaceholder"><propertyname="location"><value>classpath:config.properties</value></property></bean>