当前位置:网站首页>nacos基础(5):nacos配置入门
nacos基础(5):nacos配置入门
2022-04-23 11:18:00 【逆水行舟没有退路】
前言
如何发布配置?nacos客户端如何获取配置?
第一节 发布配置
- 打开nacos控制台,点击 配置管理>> 配置列表,点击+号添加配置

- 填写配置信息,并发布,此时查看配置列表,就会出现刚刚的配置内容。


第二节 nacos客户端获取配置
-
新建maven项目
-
引入依赖
<dependency>
<groupId>com.alibaba.nacos</groupId>
<artifactId>nacos-client</artifactId>
<version>1.3.2</version>
</dependency>
- 编写java代码
package com.it2;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.exception.NacosException;
import java.util.Properties;
public class NacosDemo01 {
public static void main(String[] args) throws NacosException {
String dataId="nacos-demo.yaml";
String group="DEFAULT_GROUP";
String serverAddr="127.0.0.1:8848";
Properties properties=new Properties();
properties.put("serverAddr",serverAddr);
ConfigService configService= NacosFactory.createConfigService(properties);
String config=configService.getConfig(dataId,group,3000);
System.out.println(config);
}
}
- 运行代码,这时我们就可以看到前面nacos里刚刚配置的内容。

版权声明
本文为[逆水行舟没有退路]所创,转载请带上原文链接,感谢
https://blog.csdn.net/u011628753/article/details/124356813
边栏推荐
- MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
- PDMS soft lithography process
- 学习 Go 语言 0x01:从官网开始
- Learn go language 0x07: stringer exercise code in go language journey
- QT 怎么把QWigdet变成QDialog
- MBA-day5數學-應用題-工程問題
- Mysql8. 0 installation guide
- MySQL分区表实现按月份归类
- Cumcm 2021 - B: préparation d'oléfines C4 par couplage éthanol (2)
- 得物技术网络优化-CDN资源请求优化实践
猜你喜欢

Mysql8. 0 installation guide

年度最尴尬的社死瞬间,是Siri给的

Microsoft Access database using PHP PDO ODBC sample

The songbird document editor will be open source: starting with but not limited to markdown

Google Earth Engine(GEE)——将原始影像进行升尺度计算(以海南市为例)

R-drop: a more powerful dropout regularization method

Excel·VBA自定义函数获取单元格多数值

CUMCM 2021-b: preparation of C4 olefins by ethanol coupling (2)

redis优化系列(二)Redis主从原理、主从常用配置

得物技术网络优化-CDN资源请求优化实践
随机推荐
学习 Go 语言 0x08:《Go 语言之旅》中 练习使用 error
Cygwin 中的 rename 用法
Learn go language 0x05: the exercise code of map in go language journey
Interprocess communication -- message queue
laravel编写Console脚本
学习 Go 语言 0x02:对切片 Slice 的理解
Mba-day5 Mathematics - application problems - engineering problems
Detailed explanation of typora Grammar (I)
Learn go language 0x04: Code of exercises sliced in go language journey
使用 PHP PDO ODBC 示例的 Microsoft Access 数据库
ffmpeg命令行常用参数
Mysql8.0安装指南
Mysql中有关Datetime和Timestamp的使用总结
R-Drop:更强大的Dropout正则方法
Detailed explanation of how to smoothly go online after MySQL table splitting
MySQL Router重装后重新连接集群进行引导出现的——此主机中之前已配置过的问题
GPU, CUDA,cuDNN三者的关系总结
Learn go language 0x03: understand the dependency between variables and initialization order
MySQL数据库事务transaction示例讲解教程
Excel·VBA数组冒泡排序函数