Having an interesting problem with Spring @Value annotation using SpEL. Setting the default value for null works for the String variable. However, for the Set variable this is not so.
So this works (varStr is null):
@Value("${var.string:#{NULL}}")
private String varStr;
while it is not (now varSet contains one element with "# {NULL}"):
@Value("#{'${var.set:#{NULL}}'.split(',')}")
private Set<String> varSet;
The question is how to make this work using the Set variable, so by default it will be null.
Your help will be greatly appreciated.
source
share