-
Notifications
You must be signed in to change notification settings - Fork 1
Configuration
Fabrice Daugan edited this page Apr 13, 2018
·
1 revision
@Autowired
private ConfigurationResource configuration;
...
configuration.get("my-key");See ConfigurationResource.java
Configuration can be retrieved:
- From built-in Spring variable resolution: static, and resolved only when the context is started
@Value("$(my-key:default-value"}
private String value;- From
ConfigurationResource, a persistent database backed and cached configuration
@Autowired
private ConfigurationResource configuration;
...
configuration.get("my-key", "default-value");
configuration.get("my-key", 42);
configuration.get("my-key");Built-in Spring property resolver use the System.getProperty then application.properties, then the default value.
For ConfigurationResource, the sequence is the same with database lookup first.
Both solutions are backed by Jasypt to protect secret from configuration files and stored sensitive data in database. It is possible to benefit the same security level for other stored data:
@Autowired
private CryptoHelper cryptoHelper;
...
cryptoHelper.encryptAsNeeded(value)
cryptoHelper.encrypt(value)
cryptoHelper.decryptAsNeeded(value)
cryptoHelper.decrypt(value)