当前位置:网站首页>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

边栏推荐
- Manhattan distance and Manhattan rectangle - print back font matrix
- [C language] string left rotation
- 对数据安全的思考(转载)
- [eolink] PC client installation
- 「 WEB测试工程师 」岗位一面总结
- Sqlmap tutorial (III) practical skills II
- How Huawei routers configure static routes
- Dynamic programming -- knapsack problem
- properties文件
- 《卓有成效的管理者》读书笔记
猜你喜欢

IDEA 新UI使用

PAT(乙级)2022年夏季考试
![[untitled]](/img/5d/028b9d19e9a2b217f40198d4631db2.png)
[untitled]

Detailed explanation of BF and KMP

Manhattan distance and Manhattan rectangle - print back font matrix

Pat (Grade B) 2022 summer exam

【eolink】PC客户端安装

LeetCode 1200. 最小绝对差

Seven imperceptible truths in software testing

Investment strategy discussion and market scale prediction report of China's solid state high power amplifier industry from 2022 to 2028
随机推荐
CoordinatorLayout+NestedScrollView+RecyclerView 上拉底部显示不全
使用Nacos管理配置
LeetCode 731. 我的日程安排表 II
异常检测方法总结
Application of Lie group in gtsam
GTSAM中ISAM2和IncrementalFixedLagSmoother说明
[API interface tool] Introduction to postman interface
Eigen sparse matrix operation
Reading notes of effective managers
Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
技术分享 | 常见接口协议解析
Overview of three core areas of Mathematics: algebra
The ECU of 21 Audi q5l 45tfsi brushes is upgraded to master special adjustment, and the horsepower is safely and stably increased to 305 horsepower
isam2运行流程
数字三角形模型 AcWing 1015. 摘花生
进程和线程的理解
[C language] string left rotation
多线程应用的测试与调试
D - How Many Answers Are Wrong
[postman] dynamic variable (also known as mock function)