您的位置:首页 > 编程语言 > Java开发

系统启动PropertyPlaceholderConfigurer加载配置到spring容器中

2016-03-30 13:48 621 查看
如下是研读大拿代码截取下来的,方便以后开发中使用

public class SystemProperties extends PropertyPlaceholderConfigurer {
protected Logger log = LoggerFactory.getLogger(this.getClass());

@Override
protected void processProperties( ConfigurableListableBeanFactory beanFactoryToProcess, Properties props) throws BeansException {
Properties result = new Properties();
if (PropertiesConfigContext.IsInited()){
result = PropertiesConfigContext.getSysproperties();
} else {
PropertiesConfigContext.initConfig();

Properties propbackup = new BackUpPropertiesLoader().getProperties();
CollectionUtils.mergePropertiesIntoMap(propbackup, result);

PropertiesConfigContext.SetConfigInitInfo(result);
}

super.processProperties(beanFactoryToProcess, result);
}
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java