I have multiple property file sources in my spring xml files, they have different order values and some are optional.
- application.properties – in the classpath, holds the default (fallback) properties (lowest priority)
- [HOSTNAME].properties – in the classpath, holds properties specific for that hostname (higher priority)
- Property file loaded by value in jndi – location specified in via jndi, highest priority.
In other words, I can override the default properties set in application.properties with properties in .properties and override those values in turn by a property file whose location is looked up by jndi.
What I would like to have however is some way for spring to give my a list of the resolved values of all the properties. Anyone know how I can do this?
It’s easy for me to get the value of a particular property but what I actually need is a list of all the resolved properties.
I have two suggestions:
PropertyPlaceholderConfigurerwith methodprocessPropertiesto populate all the resolved properties. An example is listed here.PropertyPlaceholderConfigurerimplements Spring’sOrderedinterface, you can have multiple property place holders; then, assign them theorderin the order that should be in your application. Finally, having been already extended the class, you will have access to all resolved properties in the order that should be loaded.