当前位置:网站首页>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
边栏推荐
- 学习 Go 语言 0x03:理解变量之间的依赖以及初始化顺序
- MIT:用无监督为世界上每个像素都打上标签!人类:再也不用为1小时视频花800个小时了
- MySQL8. 0 upgraded stepping on the pit Adventure
- Excel · VBA array bubble sorting function
- laravel编写Console脚本
- 用curl库压缩成发送字符串为utf8并用curl库发送
- PyTorch 神经网络训练器
- 面向全球市场,PlatoFarm今日登录HUOBI等全球四大平台
- Usage of rename in cygwin
- Microsoft Access database using PHP PDO ODBC sample
猜你喜欢
Using Baidu PaddlePaddle EasyDL to accomplish specified target recognition
Interprocess communication -- message queue
Cygwin 中的 rename 用法
PDMS soft lithography process
Excel · VBA array bubble sorting function
An interesting interview question
Jupyter lab top ten high productivity plug-ins
laravel编写Console脚本
CUMCM 2021-B:乙醇偶合制备C4烯烃(2)
Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities
随机推荐
Implementation of partition table of existing data table by MySQL
Implementation of inserting millions of data into MySQL database in 10 seconds
R-Drop:更强大的Dropout正则方法
Introduction to neo4j authoritative guide, recommended by Qiu Bojun, Zhou Hongxiang, Hu Xiaofeng, Zhou Tao and other celebrities
Promise details
Detailed explanation of how to smoothly go online after MySQL table splitting
remote: Support for password authentication was removed on August 13, 2021.
一道有趣的阿里面试题
FileProvider 路径配置策略的理解
MySQL数据库10秒内插入百万条数据的实现
活动进行时! 点击链接加入直播间参与“AI真的能节能吗?”的讨论吧!
map<QString, bool> 的使用记录
Mba-day5 Mathematics - application problems - engineering problems
PDMS soft lithography process
MySQL索引优化之分页探索详细介绍
MBA-day5数学-应用题-工程问题
2022爱分析· 工业互联网厂商全景报告
Cumcm 2021 - B: préparation d'oléfines C4 par couplage éthanol (2)
Prevent SQL injection in web projects
防止web项目中的SQL注入