Reputation: 958
I am using Spring Cloud Vault to store an API Key in production.
From reading the spring.io blog it appears I can use
@Value("${apiKey}")
String apiKey;
to access that key in vault.
This is fine when in production, but is there a way that I can set a default value/ some other way of setting up an apiKey that can be used locally for development? (preferably outside of vault if possible)
Upvotes: 0
Views: 1435
Reputation: 124441
As explained in the Spring Boot Reference Guide several sources of configuration properties are consulted. It doesn't really matter where the value for apiKey
comes from.
You have at least 3 options:
--apiKey=<your-api-key>
when starting the application locallyapplication.[properties|yaml]
used for local development. Either way the apiKey
property will be resolved locally without having to use the vault.
Upvotes: 2
Reputation: 2817
You can set a default value (if the apiKey is not found ) like this :
@Value("${apiKey:MY_KEY_HERE}")
where MY_KEY_HERE
is the default value.
Upvotes: 2