Spring自定义配置文件读取类
2015-05-16 14:07
232 查看
配置可读取自定义的properties文件
实现类MiceConfig:
配置
实现类MiceConfig:
public class MiceConfig extends PropertyPlaceholderConfigurer { // map映射 private static Map<String, Object> ctxPropertiesMap; @Override protected void processProperties( ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException { super.processProperties(beanFactoryToProcess, props); ctxPropertiesMap = new HashMap<String, Object>(); for (Object key : props.keySet()) { String keyStr = key.toString(); String value = props.getProperty(keyStr); ctxPropertiesMap.put(keyStr, value); } } public static Object getContextProperty(String name) { return ctxPropertiesMap.get(name); } }
配置
<bean id="propertyConfigurer" class="org.mice.config.MiceConfig"> <property name="ignoreResourceNotFound" value="true" /> <property name="locations"> <list> <value>/WEB-INF/classes/dbconfig.properties</value> <value>/WEB-INF/classes/common.properties</value> </list> </property> </bean>
相关文章推荐
- Springboot 之 自定义配置文件及读取配置文件
- 自定义spring容器--spring容器读取bean配置文件的原理
- Spring-boot中读取核心配置文件application和自定义properties配置文件的方式
- 五、Springboot 之 自定义配置文件及读取配置文件
- Springboot 之 自定义配置文件及读取配置文件
- Spring读取自定义properties配置文件
- SpringBoot自定义配置文件读取
- Spring boot之读取自定义配置文件
- Springboot 之 自定义配置文件及读取配置文件注意:配置文件中的字符串不要有下划线 .配置中 key不能带下划线,value可以(下划线的坑,坑了我两天..特此纪念)
- Springboot 读取配置文件及自定义配置文件
- Springboot 之 自定义配置文件及读取配置文件
- Springboot 之 自定义配置文件及读取配置文件
- spring 读取自定义配置文件
- springBoot使用Controller读取配置文件两种方式&读取自定义配置方法
- Springboot 之 自定义配置文件及读取配置文件
- Springboot读取配置文件及自定义配置文件的方法
- Springboot 之 自定义配置文件及读取配置文件
- spring boot 添加自定义配置文件并读取属性
- [spring源码学习]三、IOC源码——自定义配置文件读取
- Spring-boot中读取config配置文件的两种方式