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
1
vote
2 answers

What's wrong with Commons Configuration AbstractConfiguration's get() and getArray()?

Using commons-configuration2:2.4. my.properties: arrayOfSingle=0xA arrayOfMultiples=0xD,0xA   CONFIG.getArray(int[].class, "arrayOfSingle")); org.apache.commons.configuration2.ex.ConversionException: The value '0xA' (class java.lang.String)…
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
1
vote
1 answer

Good example of Spring Configuration using java.util.prefs or Commons Configuration

One application I'm working on has several URLs and other information that is instance specific. The first pass uses a typical Spring PropertyPlaceholderConfigurer with a properties file:
Greymeister
  • 312
  • 4
  • 12
1
vote
0 answers

Why is my XMLBeanDeclaration is invalid after migrating to Commons Configuration 2.x?

I’m working on migrating my codebase from Commons Configuration 1.x to 2.x. However, in version 2, I receive an error indicating that the key I used in 1.x is invalid: org.apache.commons.configuration2.ex.ConfigurationRuntimeException: Passed in key…
johnnieb
  • 3,982
  • 4
  • 29
  • 32
1
vote
1 answer

Format XML output/modify Transformer in apache commons-configurations2

I am trying to migrate from the old commons-configuration to commons-configuration2 but I am having trouble formatting the XML output with indentation when using the new Configurations builder. Before I did like this, which worked…
langen
  • 740
  • 5
  • 17
1
vote
1 answer

create a commons config Configuration object from standard Properties object

I am loading settings from a YAML file and having Spring autowire the results in a Properties bean like so: @ConfigurationProperties(prefix = "myPrefix") @Bean private Properties getProperties() { return new Properties(); } However, the…
Nate Glenn
  • 6,455
  • 8
  • 52
  • 95
1
vote
2 answers

How to reload apache commons configurations2 properties

can anyone guide me on how to perform a reload of an apache commons configuration2 properties. I'm unable to find any implementation of this anywhere. The apache docs are a bit too abstract. This is what I have so far but it's not working. …
1
vote
2 answers

Apache Commons Configuration Cant save

I am using Apache Commons Configuration to keep some properties in a properties file located in a package re/iprocu/coperativeerp/config/payment/configurations.properties private PropertiesConfiguration configs = new …
Yunus Einsteinium
  • 1,102
  • 4
  • 21
  • 55
1
vote
0 answers

Is there a way to make Spring reload bootstrap properties dynamically?

I have a spring-boot app that autoconfigures an instance of Netflix's DynamicPropertyFactory. This enables us to read any properties spring is aware of plus any additional sources we specify. The issue arises when we change a spring property that…
1
vote
1 answer

Use Commons Configuration 2 as PropertySource in Spring

Commons Configuration 2.0 is out. With Commons Configuration 1.0 there was a Spring modules factory bean (org.springmodules.commons.configuration.CommonsConfigurationFactoryBean) that allows direct usage of Commons Configuration with…
Dennis Kieselhorst
  • 1,280
  • 1
  • 13
  • 23
1
vote
2 answers

Apache Commons Configurations containsKey returns false on existing key

Apologies if this is documented, but I wasn't able to find this on the official documentation. I'm using XMLConfiguration to load this file, but config.containsKey ("aliases") returns false and config.containsKey ("aliases.alias") returns true. Am I…
Vektor88
  • 4,841
  • 11
  • 59
  • 111
1
vote
0 answers

Validation of Apache Commons Configuration Values

I'm using Apache's commons-configuration (v 1.10) library to provide configuration values for my program. I use a CompositeConfiguration of a SystemConfiguration and a PropertiesConfiguration in order to allow the users to override the properties…
Trebor Rude
  • 1,904
  • 1
  • 21
  • 31
1
vote
2 answers

Properties File multi-line values using PropertiesConfiguration

So far, I have this project where I read in a properties file using PropertiesConfiguration (from Apache), edit the values I would like to edit, and then save change to the file. It keeps the comments and formatting and such, but one thing it does…
Luke Gaskell
  • 175
  • 4
  • 15
1
vote
0 answers

How to load xml configuration from stream using apache commons?

I would like to use apache commons configuration 1.10 to manage xml configurations. My configuration is in a remote server, so I need to read it from a stream. Something like java.util.Properties that has method load to read from a stream. byte[]…
theShadow89
  • 1,307
  • 20
  • 44
1
vote
1 answer

How to make empty configuration if file not found?

Using Apache Commons Configurations 1.9, how to avoid ConfigurationException upon loading a configuration file if the provided file cannot be found? The Spring app context resembles:
Adrian Shum
  • 38,812
  • 10
  • 83
  • 131
1
vote
2 answers

Find absolute path of *.properties file in Spring context

I have some legacy jars I'm trying to get to work inside a spring context. Inside my applicationContext.xml, I load the property file(s) using: ... and it works…
Jan Vladimir Mostert
  • 12,380
  • 15
  • 80
  • 137