Situation
I am inserting properties from a .properties file into fields annotated with @Value . However, these properties contain sensitive credentials, so I delete them from the repository. I still want, in case someone wants to run a project and does not have a .properties file with credentials, the default values โโwill be set in the fields.
Problem
Even if I set the default values โโfor the field itself, I get an exception when the .properties file is missing:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'xxx': Injection of autowired dependencies failed; nested exception is java.lang.IllegalArgumentException: Could not resolve placeholder 'secret' in string value "${secret}"
Here is the annotated field:
@Value("${secret}") private String ldapSecret = "secret";
I expected that in this case only a simple "secret" String would be set.
source share