Reputation: 53
For Apache Commons Configuration, I am trying to load multiple java property files.
I was wondering if it's possible to "import/include" other files in one file so I only need to load the first file and the rest will all be imported.
E.g.
common.properties
include 'specific.properties'
propertyA=10
propertyB=20
specific.properties
propertyC=30
propertyD=40
So in the end I would have
propertyA=10
propertyB=20
propertyC=30
propertyD=40
Currently, I'm just using
CompositeConfiguration config = new CompositeConfiguration();
config.addConfiguration(new PropertiesConfiguration("common.properties"));
config.addConfiguration(new PropertiesConfiguration("specific.properties"));
Thanks in advance!
Upvotes: 2
Views: 1024
Reputation: 811
It is possible. Copied from documentation:
If a property is named "include", and the value of that property is the name of a file on the disk, that file will be included into the configuration.
In your case (common.properties):
include = specific.properties
propertyA = 10
propertyB = 20
specific.properties
propertyC = 30
propertyD = 40
Upvotes: 1