当前位置:网站首页>Manage configuration using Nacos
Manage configuration using Nacos
2022-07-06 06:14:00 【Snow peak expensive】
List of articles
- One 、 Plus dependence
- Two 、 Appointment
- 3、 ... and 、bootstrap.yml
- Four 、 Add configuration 
- 5、 ... and 、 Business code fetching configuration
- 6、 ... and 、@RefreshScope
- 7、 ... and 、 Rollback configuration
- 8、 ... and 、 A general configuration of microservices
- Nine 、 Configuration sharing of different microservices
- Ten 、 Remote configuration and local configuration priority
One 、 Plus dependence
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
Two 、 Appointment
The two ends of the arrow connection should be consistent , There is a bootstrap.yml, Corresponding Nacos Configuration of multiple specified environments on . Specify when the microservice starts active, Will go Nacos Find the configuration of the corresponding environment .
3、 ... and 、bootstrap.yml
spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
file-extension: yaml
application:
name: content-center
profiles:
active: dev
Four 、 Add configuration 
At this point, this configuration has been configured to the development environment
5、 ... and 、 Business code fetching configuration
@Value("${your.config}")
private String config;
6、 ... and 、@RefreshScope
Annotate the class that gets the configuration , Can dynamically obtain Nacos To configure .
7、 ... and 、 Rollback configuration

8、 ... and 、 A general configuration of microservices
1. The general configuration of all environments is written in :{ Microservice name }.yaml in
2.yaml The priority of the :
Appoint profile Of yaml > { Microservice name }.yaml
Nine 、 Configuration sharing of different microservices
ext-config The way
spring:
cloud:
nacos:
config:
server-addr: 127.0.0.1:8848
file-extension: yaml
ext-config:
# Shared DataId,yaml Suffixes must not be less , Only support yaml/properties
# More backward , The higher the priority priority common2.yaml > common1.yaml
- data-id: common1.yaml
# common1.yaml Where group
group: DEFAULT_GROUP
# Whether to allow refresh , Default false
refresh: true
- data-id: common2.yaml
group: DEFAULT_GROUP
refresh: true
application:
name: content-center
profiles:
active: dev
shared-dataids The way
spring:
cloud:
nacos:
config:
# Shared configuration DataId, Multiple uses , Separate
# More backward , The higher the priority ;common2.yml > common1.yaml
# .yaml Suffixes must not be less , Only support yaml/properties
shared-dataids: common1.yaml,common2.yaml
# Which sharing configurations support dynamic refresh , Multiple uses , Separate
refreshable-dataids: common1.yaml
server-addr: 127.0.0.1:8848
file-extension: yaml
application:
name: content-center
profiles:
active: dev
Just copy the code in two ways to bootstrap in , And in Nacos Configure in the corresponding group common1.yaml,common2.yaml that will do .
Ten 、 Remote configuration and local configuration priority
Default Nacos Configuration on >application.yml & bootstrap.yml
Also available at Nacos Modification priority of a configuration file on

边栏推荐
- 公司视频加速播放
- F - True Liars (种类并查集+DP)
- Fault, error, failure of functional safety
- Digital triangle model acwing 1015 Picking flowers
- 曼哈顿距离和-打印菱形
- P问题、NP问题、NPC问题、NP-hard问题详解
- Understanding of processes and threads
- [leetcode] day96 - the first unique character & ransom letter & letter ectopic word
- 【eolink】PC客户端安装
- Function of contenttype
猜你喜欢

Function of activation function
![[postman] collections - run the imported data file of the configuration](/img/85/7ac9976fb09c465c88f376b2446517.png)
[postman] collections - run the imported data file of the configuration
![[postman] test script writing and assertion details](/img/65/6520fe78bb2b3ff99f16d09ea8c0d1.png)
[postman] test script writing and assertion details

误差的基本知识

异常检测方法总结

Caused by:org. gradle. api. internal. plugins . PluginApplicationException: Failed to apply plugin

LeetCode 739. 每日温度

Isam2 operation process

全链路压测:构建三大模型

Detailed explanation of BF and KMP
随机推荐
[eolink] PC client installation
Isam2 operation process
【C语言】字符串左旋
Online and offline problems
D - How Many Answers Are Wrong
测试周期被压缩?教你9个方法去应对
selenium源码通读·9 |DesiredCapabilities类分析
【微信小程序】搭建开发工具环境
MySQL之数据类型
Introduction to promql of # yyds dry goods inventory # Prometheus
Sqlmap tutorial (III) practical skills II
leaflet 地图
Arrays and collections
JMeter做接口测试,如何提取登录Cookie
D - How Many Answers Are Wrong
Luogu p1460 [usaco2.1] healthy Holstein cows
「 WEB测试工程师 」岗位一面总结
数字三角形模型 AcWing 1015. 摘花生
[web security] nodejs prototype chain pollution analysis
【eolink】PC客户端安装