Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to load multiple configuration files using apache common configuration(java)

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.

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

Thanks in advance

like image 430
shashuec Avatar asked Feb 25 '11 08:02

shashuec


1 Answers

I think you want something similar to the mechanism described here:

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

Reference:

  • CompositeConfiguration
like image 67
Sean Patrick Floyd Avatar answered Oct 05 '22 15:10

Sean Patrick Floyd