Search code examples
javaspringconfiguration-files

What are possible lightweight Java configuration libraries for handling complex configuration?


I have a need for processing a relatively complex set of configuration parameters for a java application. The requirements are roughly:

  • Nested configuration values with lists, maps, etc. - not just plain key/value pairs
  • Multiple configuration files where later configuration files can intelligently override settings from earlier configuration files.
  • Multiple references to the same configured item from different places
  • Inheritable configured objects, so anew object can copy configuration from a previous object can just change specific things
  • Very little code needed for a new configuration options - the optimal would be to just add an @Configurable annotation to a field, or something similar

Now, I know that Spring fulfills all of these in a certain way. However, it has some disadvantages, though none fatal:

  • Spring is not really optimized as a configuration language, as it is somewhat more concerned about dependency injection
  • The XML configuration files are more meant to be shipped inside a JAR file and not modified by the end user, with all the configurable properties referenced via a separate properties file or similar - where as I need the configuration file to be complete and easily end-user modifiable
  • Spring configuration is somewhat tedious when there are online configuration refreshes without terminating ongoing connections and when there needs to be separate configuration checking primitives that need to validate a configuration fully, but not actually do anything

So, I am asking, can you think of any alternatives that would fulfill my requirements?

I sort of like YamlBeans, but it is lacking a few features.


Solution

  • Have you already had a look at Apache Commons Configuration?