Settings4j provides you with a lightweight Java library that allows programmers not to worry about the location where the configuration settings are stored.
Designed to ease the development process, settings4j can decide where the value will be placed, so the developer does not have to select the type of configuration.
Simply add to your pom.xml:
<dependency>
<groupId>org.settings4j</groupId>
<artifactId>settings4j</artifactId>
<version>2.0.1</version>
</dependency>
See https://maven-badges.herokuapp.com/maven-central/org.settings4j/settings4j
You don't know how your Project should be configured (System Properties, JNDI, Preferences, others...)?
Use settings4j:
String myValue = Settings4j.getString("SOME_KEY");
The Default Configuration works in the following Order to get Configuration-Values:
- Lookup in System.getProperty(...)
- Lookup in JNDI Context
- Lookup in Preferences.userRoot() and then Preferences.systemRoot()
- Lookup in Classpath
With Settings4j, your Operation can decide how the application should be configured.
Simply put your own settings4j.xml into the root-classpath or configure it manual in Java.
See http://settings4j.org/archiv/latest/config.html
You probable uses "@Value" annotation like that:
@Value("${SOME_KEY}")
String myValue;
simply configure Settings4jPlaceholderConfigurer and your "@Value" Annotations will be processes through Settings4j:
<beans>
<!-- The PlaceholderConfigurer: -->
<bean class="org.settings4j.helper.spring.Settings4jPlaceholderConfigurer" />
</beans>
(Works also with Spring Java Based Configuration)
See http://settings4j.org/archiv/latest/configSpringPlaceholder.html
This project is licensed under Apache License, Version 2.0.
See https://github.com/brabenetz/settings4j/blob/master/LICENSE.txt