One - One Code All

Blog Content

Spring.properties文件中将元素作为数组获取

Java   2010-11-17 20:17:24


属性文件中定义如下数组:

base.module.elementToSearch=1,2,3,4,5,6


Java类中加载这样的数组如下:

@Value("${base.module.elementToSearch}")
private String[] elementToSearch;


如果你使用的是逗号以外的不同的分隔符,也可以使用该分隔符。

@Value("#{'${my.config.values}'.split(',')}")
private String[] myValues;   // could also be a List



属性文件中,定义如下:

my.config.values=value1, value2, value3

# 也可以在属性文件中这么定义:
myapp.configs[0].appid = 111111
myapp.configs[0].secret= 222222



上一篇:pandas中的DataFrame按指定顺序输出所有列
下一篇:pandas将列表List转换为数据框Dataframe,pd.DataFrame(list)

The minute you think of giving up, think of the reason why you held on so long.