如何使用apache通用配置(java)加载多个配置文件 [英] How to load multiple configuration files using apache common configuration(java)

查看:35
本文介绍了如何使用apache通用配置(java)加载多个配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用 apache 通用配置类加载的主 conf 文件.我有一个要求,用户可以指定一个 conf 文件,这些文件中的值将覆盖主 conf 中的值.

I have a main conf file which I load using apache common configuration class. I have a requirement where user can specify a conf file and values in those file will override the values in main conf.

请建议我如何在 apache 通用配置类或任何其他开源类中实现这一点.

Please suggest me how we can do that in apache common configuration class or any other open source class to achieve this.

提前致谢

推荐答案

我想你想要类似于 此处描述的机制:

CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new PropertiesConfiguration("user.properties"));
config.addConfiguration(
    new PropertiesConfiguration("application.properties"));
// user preferences have precedence over application preferences

参考:

这篇关于如何使用apache通用配置(java)加载多个配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆