Questions tagged [apache-commons-config]

The Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources.

The Apache Commons Configuration software library provides a generic configuration interface which enables a Java application to read configuration data from a variety of sources. Commons Configuration provides typed access to single, and multi-valued configuration parameters as demonstrated by the following code:

Double double = config.getDouble("number");
Integer integer = config.getInteger("number");

Configuration parameters may be loaded from the following sources:

  • Properties files
  • XML documents
  • Windows INI files
  • Property list files (plist)
  • JNDI
  • JDBC Datasource
  • System properties
  • Applet parameters
  • Servlet parameters

Different configuration sources can be mixed using a ConfigurationFactory and a CompositeConfiguration. Additional sources of configuration parameters can be created by using custom configuration objects. This customization can be achieved by extending AbstractConfiguration or AbstractFileConfiguration.

Official Website: http://commons.apache.org/configuration/

Useful Links:

146 questions
125
votes
4 answers

How to write multiple line property value using PropertiesConfiguration?

I have a properties file where a property has a comma-separated list value. How can I write these property values so that they span multiple lines? (Maybe a backslash after the comma?) I can't find anything about this or at least about escaping…
Uhkkgjhfjf Jgkjkhj
  • 1,251
  • 2
  • 8
  • 4
24
votes
4 answers

Guice and general application configuration

For a monitoring software written in Java I consider using Google Guice as DI provider. The project needs to load its configuration from an external resource (file or database). The application is designed to run in standalone mode or in a servlet…
mjn
  • 36,362
  • 28
  • 176
  • 378
20
votes
2 answers

Very simple Apache-commons configuration example throws NoClassDefFoundError

I'm trying to test a very simple example given in the Apache-commons configuration library user's guide regarding declaring and creating beans. I copied the code in the example almost word by word, and yet I'm getting a NoClassDefFoundError…
Joe
  • 2,994
  • 5
  • 31
  • 34
15
votes
3 answers

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…
shashuec
  • 684
  • 8
  • 20
15
votes
1 answer

How to set logback configuration file at runtime?

I would like to have a logback.xml file for production and another one with different parameters on my staging environment. My code is able to automatically know at runtime if it is on production or runtime. Is there a way to set the logback…
poiuytrez
  • 21,330
  • 35
  • 113
  • 172
13
votes
3 answers

How to get list of properties using apache.commons

I need to get the list of properties which are in the .properties file. For example, if have the following .properties file: users.admin.keywords = admin users.admin.regexps = test-5,test-7 users.admin.rules =…
Nikitin Mikhail
  • 2,983
  • 9
  • 42
  • 67
12
votes
2 answers

Apache Commons Configuration: ClassNotFoundException: org.apache.commons.beanutils.DynaBean

My POM contained: org.apache.commons commons-configuration2 2.3 Both sample codes from Quick start guide, Reading a…
8
votes
1 answer

Alternative to apache commons configuration for reading properties from database

I have just discovered that Apache commons-configuration can read properties from a DataSource, but it does not cache them. My application needs to read properties a lot of times and it is to slow to access the database each time. I have a Camel…
mgiammarco
  • 371
  • 5
  • 16
7
votes
3 answers

Why is Maven not resolving all dependencies for commons-configuration?

Summary When trying XMLConfiguration configuration = new XMLConfiguration("config/config.xml"); with only commons-configuration 1.10 I need to add more depencies (namely commons-collections not newer than 3.2.1) to my maven setup. Why is that so and…
Sebastian Höffner
  • 1,864
  • 2
  • 26
  • 37
7
votes
5 answers

NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException

I have an app in which I need to parse configuration file and when run this program on server it gives the following trace: java.lang.NoClassDefFoundError: org/apache/commons/configuration/ConfigurationException at…
Nikitin Mikhail
  • 2,983
  • 9
  • 42
  • 67
6
votes
2 answers

what is apache common configuration

Can some one throw some light on what is common configuration (apache common configuration)? It will he helpful if some one can explain it with some use-case. Also any links (other than google) from where I can get some useful information are very…
Rohit Jain
  • 159
  • 1
  • 4
  • 12
6
votes
1 answer

Format XML output with apache commons configuration XMLConfiguration

I am using the apache commons configuration XMLConfiguration to build and save an XML file. When saving there is no formatting. I get something like: I know there are plenty of ways to use some other…
MattRS
  • 428
  • 5
  • 8
6
votes
1 answer

Is there a way to provide default values for env variables in a properties file with apache-commons?

I'm using org.apache.commons:commons-configuration2:2.5 to read config parameters from a config file. In my application.properties, I want to specify default values for environment variables in case one of these has not been set, e.g. like so…
xJREB
  • 333
  • 5
  • 10
6
votes
2 answers

Can I use both arrays and non-arrays with Apache Commons Config?

With the following properties file: foo=hello, world! bar=first,second I would like to retrieve the first item as a string and the second as an array. I would have thought that getString vs getStringArray would deal with this, but it doesn't -…
bacar
  • 9,761
  • 11
  • 55
  • 75
6
votes
2 answers

Any Apache Commons-Configuration replacements / competitors?

I recently tried to use Apache Commons-Configuration to manage some local XML configuration files. It drastically falls short on ease of use (can't load empty config files, CombinedConfiguration requires utilization of underlying Configurations for…
1
2 3
9 10