java:(简化起见, 使用lombok)
@Data
@Configuration
@ConfigurationProperties(prefix = "myconfig")
public class MyConfig {
/**
* 以map组装
*/
Map<String, MyBean> map;
/**
* 以List组装
*/
List<MyBean> list;
@Data
public static class MyBean {
Integer id;
String name;
}
}
yml
myconfig:
map:
aaa:
id: 1
name: a
bbb:
id: 2
name: b
list:
- id: 3
name: c
- id: 4
name: d
网友评论