我是靠谱客的博主 威武野狼,这篇文章主要介绍基于spring的PropertySource类实现配置的动态替换,现在分享给大家,希望可以做个参考。

public class ConfigPropertySource extends PropertySource<Properties> implements PriorityOrdered, BeanFactoryPostProcessor, EnvironmentAware{

public void init() {
this.loadConfig();
this.env.getPropertySources().addFirst(this);
}

private Properties parseConfig(String config) {
Properties properties = new Properties();
if(StringUtils.isNotEmpty(config)) {
try {
properties.load(new StringReader(config));
} catch (Exception var4) {
throw new IllegalArgumentException("detail center parse config error, config:" + config, var4);
}
}

return properties;
}

public Object getProperty(String name) {
return this.source.get(name);
}

}

转载于:https://www.cnblogs.com/sidesky/p/10536800.html

最后

以上就是威武野狼最近收集整理的关于基于spring的PropertySource类实现配置的动态替换的全部内容,更多相关基于spring内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(35)

评论列表共有 0 条评论

立即
投稿
返回
顶部