当前位置:网站首页>Application configuration management, basic principle analysis
Application configuration management, basic principle analysis
2022-06-21 12:57:00 【51CTO】
The project can be a little messy , But the configuration cannot be ambiguous ;
One 、 Configuration architecture
In the code engineering of microservices , Configuration management is a complex thing , That is, it is necessary to take configuration isolation measures for each environment , You also need to ensure that the configuration of the production environment is secure ; If enough microservices are divided , Also consider the efficiency of configuring updates ;

Under normal circumstances , In the system of configuration management , There are four main environments : Development 、 test 、 Grayscale 、 production ; Generally speaking, in addition to the O & M team , Other personnel do not have permission to view grayscale and production configuration , To ensure the security of the configuration ; Two sets of services will be set up in the configuration center : R & D and production are deployed independently .
Two 、 Configuration mode
There are many configurations involved in the project , There are many types , But from the big structure, it can be divided into : Engineering level 、 Application level 、 Component level three block ; In fact, this is just a simple view of configuration from the perspective of code engineering , If continuous integration 、 If automation related modules are also taken into account , Configuration management will be more complex ;

From a development perspective , It mainly manages the application level configuration , In the framework of microservices , There are many different services with the same configuration , There are also various differentiated user-defined parameters , Therefore, there is a certain complexity in maintenance ;

In a single service project , Only one... Will exist in the application bootstrap.yml The configuration file , The configuration content is basically the service name , And configuration center address , Other complex configurations are closed for maintenance , Avoid security problems caused by core content leakage ;

The configuration body is usually split into the following levels : environmental control , Used to identify grayscale and production ; Application basis , Manage and load common configurations for each service ; Service differences are configured in separate files ; And manage multiple configurations by categories and layers ; So as to ensure the safety of configuration and reduce the difficulty of maintenance .
3、 ... and 、Nacos To configure
First of all, from bootstrap.yml File as a starting point , Take the common Nacos Component as an example , Focus on the basic principles , To analyze how the service project is loaded Nacos Configuration center parameters ;

Component configuration : Configuration logic , A single server provides information about its own configuration parameters , From the source code of service management in the previous article , This is a very common method ; Based on this information, we need to Nacos Load the configuration in the service ;
Load logic : Service startup , First read based on the corresponding parameters Nacos Configured in , The data is then parsed and Spring Frame to load , The loading process passes MapPropertySource classes Key and Value The read ;
Request service : The service side and Nacos Center pass Http Request to interact , adopt Get Request to carry parameters , call Nacos Central Services , So as to obtain the corresponding configuration ;
Four 、Spring load
From the structure diagram of the source code , The loading logic of the configuration file is also implemented using the event model , This is described in detail in the previous task management ; The core function of configuration is to load and boot when the program starts , The key here is to understand EnvironmentPostProcessor Interface design of ;

EnvironmentPostProcessor Interface : Load the custom environment of the application ;
SpringApplication: Used to start and boot applications , Provides creation of program context instances , Initialize listener , Container refresh and other core logic , Can revolve around run() Method to debug and analyze ;
ConfigurableEnvironment: The core interface of environment configuration , Involves identification of the current configuration file , namely profiles.active; And the ability to parse configuration files , namely PropertyResolver; stay Loader The inner class provides the implementation of construction methods and loading logic .
5、 ... and 、 Reference source code
边栏推荐
- 小程序直播互动功能运行在App里?
- Three structures of program - system learning I
- 【Appium踩坑】关闭inspector后打开weditor,uiautomator2.exceptions.NullPointerExceptionError: -32001 Jsonrpc er
- 【深入理解TcaplusDB技术】TcaplusDB业务数据备份
- 如何编写测试用例
- Educoder table label - basic table structure
- What do you mean by concurrency, concurrency, and high concurrency?
- Router telnet and ACL configuration
- Postgre SQL 支持的数据类型分类
- 显示Oracle某一张表的所有索引
猜你喜欢

Technical scheme for environmental monitoring system of power distribution room

cartographer_ ceres_ scan_ matcher_ 2d

Educator web exercise - create a drop-down list

Isn't this another go bug?

Apache ShardingSphere 5.1.2 发布|全新驱动 API + 云原生部署,打造高性能数据网关

Centos7 deploying MySQL environment

Annual special analysis of China Mobile Banking in 2022

Educoder Web练习题---创建文本区域

2022年中国手机银行年度专题分析

计算距离的几种方式汇总
随机推荐
Educoder Web练习题---文本层次语义元素
CP 指令学习
scrapy_redis分布式爬虫
Technical scheme for environmental monitoring system of power distribution room
curl常用参数详解及示例
How to delete floating IP manually
[upgraded student information management system] + file operation + more details
Educoder Web练习题---表单的结构
Educoder 表格标签—表格高级样式的设置
Iclr2022 | training billion level parameter GNN for molecular simulation
Not only zero:bmtrain technology principle analysis
Association condition of SQL left connection
uva11292
Deep learning practice (10): 3D medical image segmentation using pytorch
Matplotlib drawing tips
塔米狗 热门资讯:厦门产权交易中心再创第一次!
Efficient remote office manual | community essay solicitation
Distributed transaction processing scheme big PK
Generalized Focal Loss: Learning Qualified and Distributed Bounding Boxes for Dense Object Detection
启牛商学院app下载证券开户,是安全的吗?有风险嘛?