@Value injection map, List, yaml format

Original link: https://blog.csdn.net/inquesiting/article/details/82984017

Use @Value injection map, List

Entity class

@Value("#{'${list}'.split(',')}")
private List<String> list;

@Value("#{${maps}}")  
private Map<String,String> maps;

Profiles

list: topic1,topic2,topic3
maps: "{key1: 'value1', key2: 'value2'}"

ps: Note that the above parsing map, must use "," the map corresponding to wrap value, or else parse fails, it can lead to turn into Map <String, String>.

Guess you like

Origin blog.csdn.net/wenqiangluyao/article/details/100122414