当前位置:网站首页>Config server configuration center of Nacos series
Config server configuration center of Nacos series
2022-06-13 05:40:00 【codain】
We talked about before Naming Server, This is Nacos One of the two functions , For registration and discovery , So the other one is Config Server, This is the configuration center , amount to SCN Medium Spring Cloud Config, So we use the direct integration method , Let's experience it Config Server
1、 Create a monomer SpringBoot engineering
POM The information is as follows :
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.5.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-discovery-spring-boot-starter</artifactId>
<version>0.2.4</version>
</dependency>
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>nacos-config-spring-boot-starter</artifactId>
<version>0.2.4</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>2、 add to ConfigServer Configuration information
nacos.config.server-addr=127.0.0.1:88483、 Create an interface class ConfigController, Test remote reading of configuration center data
@RestController
// Configure data sources Whether to automatically refresh
@NacosPropertySource(dataId = "nacos",autoRefreshed = true)
public class ConfigController {
@NacosValue(value = "${value:Hello world}",autoRefreshed = true)
private String value;
@GetMapping("/config")
public String get(){
return value;
}
}4、 start-up Nacos
There are two ways to create configuration information
① Call directly Nacos Of API Interface :
http://127.0.0.1:8080/nacos/v1/cs/configs?dataId=nacos&group=DEFAULT_GROUP&content= Hello , The world
② Use Nacos Console direct configuration

5、 The browser accesses the local interface
visit :http://localhost:8080/config
The return is Nacos Configure the contents of the center : Hello , The world
This is the end of the integration test , You can also continue to call API Or modify it on the console value value , Then ask again , Take a look at the configuration above autoRefreshed Whether the automatic refresh takes effect
边栏推荐
- Pyqt5 module
- Browser screenshot method (long screenshot, node screenshot, designated area screenshot)
- Enhanced for loop
- [reprint] complete collection of C language memory and character operation functions
- Three paradigms of MySQL
- About Evaluation Metrics
- KVM virtualization management tool
- Difference between deviation and variance in deep learning
- 若依框架=》如何设置导入导出模板全局为文本格式(解决科学计数问题)
- Introduction to R language 4--- R language process control
猜你喜欢

KVM hot migration for KVM virtual management

Information collection for network security (2)

10 signalstartevent and signalcatchingevent of flowable signal events

The reason why the process cannot be shut down after a spark job is executed and the solution

20 flowable container (event sub process, things, sub process, pool and pool)

MySQL transactions and foreign keys

2021.9.30学习日志-postman

Case - grade sorting - TreeSet set storage

2 first experience of drools

Automatic database backup (using Navicat)
随机推荐
使用cmake交叉編譯helloworld
Course outline of market drawing 1- basic knowledge
How to set the import / export template to global text format according to the framework = (solve the problem of scientific counting)
Solve the problem of garbled code in the MySQL execution SQL script database in docker (no need to rebuild the container)
OpenGL馬賽克(八)
MySQL main query and sub query
2020 personal annual summary
计算两个时间相差的天数(支持跨月、跨年)
One of PowerShell optimizations: prompt beautification
Django uploads local binaries to the database filefield field
Create a harbor image library from the command line
15 inclusivegateway and eventgateway of flowable gateway
Mongodb Multi - field Aggregation group by
Detailed explanation of R language sparse matrix
16 the usertask of a flowable task includes task assignment, multi person countersignature, and dynamic forms
Case - recursive factorial (recursive)
System performance monitoring system
Explanation of service registration and discovery API of Nacos series
Initial redis experience
Hainan University Postgraduate Entrance Examination electronic information (085400) landing experience
