当前位置:网站首页>Nacos configuration in the project of battle
Nacos configuration in the project of battle
2022-07-30 10:14:00 【Fairy to carry】
目录
场景:Build a cluster like this,The configuration file used by multiple nodes is definitely similar,So we can read our configuration files in the configuration center,或者说,Use the idea of variable separation, 开发者通常会将一些需要变更的参数、变量等从代码中分离出来独立管理,以独立的配置文件的形式存在.目的是让静态的系统工件或者交付物(如 WAR,JAR 包等)更好地和实际的物理运行环境进行适配.
There is no common problem with Unified Configuration Center:
- 配置文件分散在各个项目里,不方便维护
- 配置内容安全与权限
- 更新配置后,项目需要重启
nacos配置中心:系统配置的集中管理(编辑、存储、分发)、动态更新不重启、回滚配置(变更管理、历史版本管理、变更审计)等所有与配置相关的活动.

读取nacos配置文件
1.Create first

2.输入配置信息
${prefix}-${spring.profile.active}.${file-extension}
服务名称-dev环境.File extension type

springBoot配置文件加载顺序
这里主要是说明application和bootstrap的加载顺序.
1.bootstrap.yml(bootstrap.properties)先加载
2.application.yml(application.properties)后加载
bootstrap.yml 用于应用程序上下文的引导阶段.
bootstrap.yml 由父Spring ApplicationContext加载.
父ApplicationContext 被加载到使用 application.yml 的之前.
If the environment is configured
spring.profiles.active=dev——>就会加载application-dev.properties文件
bootstrap和application的区别
bootstrap.yml 和application.yml 都可以用来配置参数.
bootstrap.yml 可以理解成系统级别的一些参数配置,这些参数一般是不会变动的.
application.yml 可以用来定义应用级别的.
修改bootstrap.properties配置文件
里面的配置的dataIdIt is a node of the configuration center
#配置中心地址
spring.cloud.nacos.config.server-addr=82.157.198.247:8848
#spring.profiles.active=dev
# 该配置影响统一配置中心中的dataId
spring.application.name=service-statistics导入依赖
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
</dependency>
命名空间切换->配置不同环境的配置文件


Practice switching between different namespaces

Then go to the configuration list to see
Can be cloned into other environments

We can specify which environment is in the configuration file

Then in servicebootstrap中进行修改,Add the specified environment namespace
Multi-file configuration read
1. 在生产devConfigure two configuration files in the environment

2.Then again in servicebootstrap文件中进行配置,Read multiple configuration files
Remember to enable dynamic refresh configuration,否则配置文件修改,工程无法感知

边栏推荐
- 这种叫什么手法
- Re16: Read the paper ILDC for CJPE: Indian Legal Documents Corpus for Court Judgment Prediction and Explanation
- A near-perfect Unity full-platform hot update solution
- Basic operations of sequence table in C language
- 快解析结合用友时空
- Do you really understand the 5 basic data structures of Redis?
- Quick Start Tutorial for flyway
- Meikle Studio-Look at the actual combat notes of Hongmeng device development six-wireless networking development
- 大数据产品:标签体系0-1搭建实践
- By building a sequence table - teach you to calculate time complexity and space complexity (including recursion)
猜你喜欢

Domino服务器SSL证书安装指南

快解析结合任我行crm

Re17:读论文 Challenges for Information Extraction from Dialogue in Criminal Law

JCL 学习

MFCC转音频,效果不要太逗>V<!

梅科尔工作室-看鸿蒙设备开发实战笔记五——驱动子系统开发

包、类及四大权限和static

Re19: Read the paper Paragraph-level Rationale Extraction through Regularization: A case study on European Court

Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court

flowable workflow all business concepts
随机推荐
hcip06 ospf特殊区域综合实验
Re15:读论文 LEVEN: A Large-Scale Chinese Legal Event Detection Dataset
leetcode 剑指 Offer 10- I. 斐波那契数列
flowable workflow all business concepts
(***重点***)Flink常见内存问题及调优指南(一)
4、yolov5-6.0 ERROR: AttributeError: ‘Upsample‘ object has no attribute ‘recompute_scale_factor‘ 解决方案
ThreadLocal内存泄漏是伪命题?
百度推广助手遇到重复关键字,验证错误,怎么一键删除多余的
Determine whether a tree is a complete binary tree - video explanation!!!
Security思想项目总结
Re19:读论文 Paragraph-level Rationale Extraction through Regularization: A case study on European Court
flyway的快速入门教程
Re18: Read the paper GCI Everything Has a Cause: Leveraging Causal Inference in Legal Text Analysis
JVM内存布局、类加载机制及垃圾回收机制详解
时刻铭记:总有一天你将破蛹而出
Study Notes 11--Direct Construction of Local Trajectories
学习笔记11--局部轨迹直接构造法
Materialist Dialectics - Conditionalism
Redis Desktop Manager 2022.4.2 released
OC-ARC(Automatic Reference Counting)自动引用计数