首页 > 其他分享 >nacos如何使用占位符${}进行参数配置

nacos如何使用占位符${}进行参数配置

时间:2022-12-26 10:44:18浏览次数:49  
标签:system nacos header host 参数 占位 port

有的时候,我们的nacos会出现一个配置文件里,有多个配置项对应的值都是一样的,这个时候nacos就可以用到占位符${}进行参数配置。

例如下面的这个配置

system:
  mapApi:
    host: http://192.168.11.222:
    port: 7777
    header: Authorization
    timeout: 100000
  bigDataApi:
    host: http://192.168.11.222:
    port: 8888
    header: Authorization
    timeout: 200000

可以使用$占位符,进行如下配置

system:
  mapApi:
    host: http://192.168.11.222:
    port: 7777
    header: Authorization
    timeout: 100000
  bigDataApi:
    host: ${system.mapApi.host}
    port: 8888
    header: ${system.mapApi.header}
    timeout: 200000

nacos使用占位符${}进行参数配置后,固定相同值的属性以后就只要改一遍就可以了,是不是很方便?

标签:system,nacos,header,host,参数,占位,port
From: https://www.cnblogs.com/shamo89/p/17005188.html

相关文章