properties和yml加载list
方式一:
shuhai:
test:
list: 12,13,14
@Value(“#{‘${shuhai.test.list}’.split(‘,’)}”) private List list;
@Value(“${shuhai.test.list}”) private List list;
方式二:
shuhai:
test:
list: >
12
13
14
@Value(“${shuhai.test.list}”) private List list;
方式三:
shuhai:
test:
list:
- 12
- 13
- 14
如下配置才能生效,@Value会报错
标签:shuhai,List,list,private,yaml,Value,test,properties From: https://blog.51cto.com/u_11906056/6985121@Setter @Getter @Component @ConfigurationProperties(“shuhai.test”) public class TestConfig {
private List<String> list;
}