So my application.yml would be something like this:
urls:
login: http://mylogin.url
restInterceptor:
log:
fieldsToHide: {'${urls.login}':'password'}
And I'd need this in my java code:
private Map<String, String> fieldsToHide;
First I tried with the @Value
annotation, like this:
@Value("${restInterceptor.log.fieldsToHide}")
private Map<String, String> fieldsToHide;
But it fails. It seems that you cannot inject a map from a yaml with the @Value
annotation, so I tried the solution in this question.
@Service
@EnableConfigurationProperties
@ConfigurationProperties(prefix = "restInterceptor.log")
public class MyClass {
private Map<String, String> fieldsToHide;
And then the map gets injected, but the key's value is '${urls.login}'
instead of http://mylogin.url
.
If I configure the map in my yaml the other way round {'password':'${urls.login}'}
, it gets correctly injected with the property value.
What am I doing wrong? Is this even possible?