当前位置:网站首页>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
边栏推荐
- Top slide immersive dialog
- MySQL main query and sub query
- How to Algorithm Evaluation Methods
- [reprint] complete collection of C language memory and character operation functions
- 13 cancelendevent of a flowable end event and compensationthrowing of a compensation event
- Small project - household income and expenditure software (1)
- RT thread console device initialization
- Shell instance
- [multi thread programming] the future interface obtains thread execution result data
- About Evaluation Metrics
猜你喜欢

Automatic database backup (using Navicat)

Case - the list set stores student objects and traverses them in three ways

OpenGL马赛克(八)

priority inversion problem

Problems encountered in the use of PgSQL

Install harbor (online offline)

MySQL log management and master-slave replication

SQL table columns and statements of database

Mysql database crud operation

OpenGL馬賽克(八)
随机推荐
ZABBIX proxy, sender (without agent monitoring), performance optimization
MySQL main query and sub query
Quartz basic use
OpenGL Mosaic (8)
计算两个时间相差的天数(支持跨月、跨年)
Implementation of concurrent programming locking
Small project - household income and expenditure software (1)
MySQL basic query
Case - the list set stores student objects and traverses them in three ways
Solve the problem of garbled code in the MySQL execution SQL script database in docker (no need to rebuild the container)
Bicolor case
ZABBIX wechat alarm
KVM virtualization management tool
MySQL built-in functions
Shell instance
Anaconda configuring the mirror source
Fast power code
A simple recursion problem of linked list
Three paradigms of MySQL
Explanation of service registration and discovery API of Nacos series
