当前位置:网站首页>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:8848
3、 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
边栏推荐
- How to Algorithm Evaluation Methods
- 行情绘图课程大纲1-基础知识
- Set the correct width and height of the custom dialog
- KVM virtualization management tool
- Case - simulated landlords (primary version)
- First assessment
- Cross compile HelloWorld with cmake
- Unity游戏优化[第二版]学习记录6
- 使用cmake交叉編譯helloworld
- 19 calling subprocess (callactivity) of a flowable task
猜你喜欢
Mongodb multi field aggregation group by
MySQL log management and master-slave replication
Etcd understanding of microservice architecture
SQL table columns and statements of database
Validation set: ‘flowable-executable-process‘ | Problem: ‘flowable-servicetask-missing-implementatio
Web site learning and sorting
Solution to prompt "permission is required to perform this operation" (file cannot be deleted) when win10 deletes a file
Quartz basic use
MongoDB 多字段聚合Group by
Use the browser to cut the entire page (take chrome as an example)
随机推荐
Anaconda configuring the mirror source
Pychart error resolution: process finished with exit code -1073741819 (0xc0000005)
Unity game optimization (version 2) learning record 7
Case - recursive factorial (recursive)
OpenGL Mosaic (8)
[multi thread programming] the future interface obtains thread execution result data
KVM hot migration for KVM virtual management
12 error end event and terminateendevent of end event
Randomly fetch data from the list
MySQL basic query
About the solution of pychart that cannot be opened by double clicking
9. Errorstartevent and errorboundaryevent of error events
[thread / multithread] execution sequence of threads
Create a harbor image library from the command line
15 inclusivegateway and eventgateway of flowable gateway
Hainan University Postgraduate Entrance Examination electronic information (085400) landing experience
Case - simulated landlords (primary version)
Use the browser to cut the entire page (take chrome as an example)
MongoDB 多字段聚合Group by
安装harbor(在线|离线)