当前位置:网站首页>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 ![ Insert picture description here ](/img/f1/a0caee341d4223cf5653c8d4119a5d.png)
- 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
边栏推荐
- Eigen稀疏矩阵操作
- nodejs实现微博第三方登录
- D - How Many Answers Are Wrong
- Overview of three core areas of Mathematics: geometry
- isam2运行流程
- 功能安全之故障(fault),错误(error),失效(failure)
- Buuctf-[bjdctf2020]zjctf, but so (xiaoyute detailed explanation)
- win10无法操作(删除、剪切)文件
- [API interface tool] Introduction to postman interface
- ContentType的作用
猜你喜欢
随机推荐
[postman] collections configuration running process
[web security] nodejs prototype chain pollution analysis
Detailed explanation of BF and KMP
Embedded point test of app
对数据安全的思考(转载)
Cannot create PoolableConnectionFactory (Could not create connection to database server. 错误
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 operation process
(5) Explanation of yolo-v3 core source code (3)
Accélération de la lecture vidéo de l'entreprise
LeetCode 731. 我的日程安排表 II
Luogu p1460 [usaco2.1] healthy Holstein cows
[postman] collections - run the imported data file of the configuration
Digital triangle model acwing 1015 Picking flowers
Linux regularly backs up MySQL database
MPLS test report
10M25DCF484C8G(FPGA) AMY-6M-0002 BGA GPS模块
数学三大核心领域概述:代数
LeetCode 739. 每日温度
G - Supermarket