SpringBoot 读取yaml list

yml 的list使用方式:

1.yml配置方式:

第一种:

employee:
 name: [zhangsan,lisi, wangwu]

第二种:

employee:
 name: 
  - zhangsan
  - lisi
  - wangwu

2.配置类:

@Configuration
@ConfigurationProperties("student")
public class EmployeeConfig{
  private List<String> name;
  // getter & setter
}

然后在类中使用  EmployeeConfig 就可以获取文件中的数据了

注意:yml中的  employee 需要全小写,否则会报错

原文地址:https://www.cnblogs.com/qinxu/p/10196147.html