Adding a custom PropertySource to the environment using EnvironmentPostProcessor
In cases where the enterprise is already using a particular configuration system, custom written or off the shelf, Spring Boot provides us with a facility to integrate this into the application via the creation of a custom PropertySource
implementation.
How to do it...
Let's imagine that we have an existing configuration setup that uses a popular Apache Commons Configuration framework and stores the configuration data in XML files:
- To mimic our supposed pre-existing configuration system, add the following content to the dependencies section in the
build.gradle
file:
dependencies { ... compile project(':db-count-starter') compile("commons-configuration:commons- configuration:1.10") compile("commons-codec:commons-codec:1.6") compile("commons-jxpath:commons-jxpath:1.3") compile("commons-collections:commons-collections:3.2.1") runtime("com.h2database:h2") ... }
- Follow this up by creating...