Spring @ Insert empty default list
4 answers
@Value("#{T(java.util.Arrays).asList('${my.list.of.strings:}')}")
private List<String> myList;
it works for me using Spring 5.0.x (produces an empty list if your my.list.of.strings property is not configured in context)
after that you can easily do something like
CollectionUtils.isNotEmpty(myList)
0
source to share