文章目录
一、默认配置及多个默认参数
默认多个参数
使用逗号分隔,例如 a,b
使用数组,Set、List集合接受都可以
@Value("${sli.customize.http.port:aa,bb}")
private Set<String> notAllowUrls;
配置中心及文件
notAllowUrls: aa,bb
数组
我们可以使用逗号分隔的 list 来用于数组的注入,如下
@Value("${some.key:one,two,three}")
private String[] stringArrayWithDefaults;
@Value("${some.key:1,2,3}")
private int[] intArrayWithDefaults;
在上面第一个例子, 值为 “one”, “two”, 和 “three” 的数组将被注入到 stringArrayWithDefaults 中
在上面第二个例子, 值为 1, 2, 和 3 的数组将被注入 intArrayWithDefaults 中