I have a string in my property file
set.test=FIRST,SECOND,THIRD,THIRD
I want to inject this into a set using @Value
@Value(value = "${set.test}")
private Set<String> testSet;
Is there a way for spring to split it based on comma and load it into the set automatically or should I assign it to an array and convert it to Set?
先前的答案非常接近,这对我有效:
@Value("#{'${set.test}'.split(',')}")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.