admin管理员组

文章数量:1122846

I have a structure as below:

company: 
  employees: 
    - name: 
      age: 
    - name: 
      age: 

I have to have this structure in ConfigMap which has key, value pairs. Then I have to read this into a List<Employee> where Employees is a POJO having name and age as fields. We also have @ConfigurationProperties(prefix = "company") as class level annotation. Can I achieve this? Please advise.

@ConfigurationProperties(prefix = "company") 
class ABC {

    List<Employee> employees;
    // .....
}
class Employee {

    String name; 
    String age;
}

But the basic issue is ConfigMap has unique keys. How do I store arrays in ConfigMap and then map like above. What I expect is that the arrays of employee map to the POJO.

本文标签: spring bootHow do i read an array of values from yaml file to a ListltPOJOgt in JavaStack Overflow