Naocs配置中心配置映射List、Map、Map嵌套List等方式

编程入门 行业动态 更新时间:2024-10-24 16:26:28

Naocs配置中心配置映射List、Map、Map<a href=https://www.elefans.com/category/jswz/34/1771299.html style=嵌套List等方式"/>

Naocs配置中心配置映射List、Map、Map嵌套List等方式

一、配置映射List

1、常规逐个配置方式,示例如下:

代码:

@Data
@Configuration
@ConfigurationProperties(prefix = "list-json-str")
public class ConfListByJsonStr implements Serializable, InitializingBean {@ApiModelProperty("映射结果集")private List<ListByJsonStrDto> listJsonStrList;@Overridepublic void afterPropertiesSet() throws Exception {System.out.println("ConfListByJsonStr类afterPropertiesSet方法执行了");CollUtil.defaultIfEmpty(listJsonStrList, ListUtil.list(false)).forEach(System.out::println);}@Datapublic static class ListByJsonStrDto {@ApiModelProperty("姓名")private String name;@ApiModelProperty("年龄")private Integer age;}
}

配置内容:

list-json-str:listJsonStrList: - name: 张三age: 25- name: 李四

更多推荐

Naocs配置中心配置映射List、Map、Map嵌套List等方式

本文发布于:2023-11-15 20:52:36,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1606158.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:嵌套   方式   中心   Naocs   Map

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!