当前位置: 首页 > news >正文

淘客做自己的网站百度视频免费下载

淘客做自己的网站,百度视频免费下载,海外营销推广服务,定制网站开发app费用springboot集成nacos 1.版本2. POM依赖3. nacos服务3.1 下载nacos压缩包3.2 启动nacos 4. yaml配置5.Demo5.1 配置中心简单格式获取方式普通方式还可以再启动类上添加注解完成5.2 获取json格式的demo5.2 自动注册根据yaml配置 1.版本 nacos版本:2.3.2 springboot版本&#xff…

springboot集成nacos

  • 1.版本
  • 2. POM依赖
  • 3. nacos服务
    • 3.1 下载nacos压缩包
    • 3.2 启动nacos
  • 4. yaml配置
  • 5.Demo
    • 5.1 配置中心简单格式获取方式
    • 普通方式还可以再启动类上添加注解完成
    • 5.2 获取json格式的demo
    • 5.2 自动注册根据yaml配置

1.版本

nacos版本:2.3.2
springboot版本:2.1.3.RELEASE

2. POM依赖

           <dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-discovery-spring-boot-starter</artifactId><version>0.2.3</version></dependency><dependency><groupId>com.alibaba.boot</groupId><artifactId>nacos-config-spring-boot-starter</artifactId><version>0.2.3</version></dependency>

3. nacos服务

3.1 下载nacos压缩包

https://github.com/alibaba/nacos/releases

3.2 启动nacos

Linux/Unix/Mac
启动命令(standalone代表着单机模式运行,非集群模式):sh startup.sh -m standalone如果您使用的是ubuntu系统,或者运行脚本报错提示[[符号找不到,可尝试如下运行:bash startup.sh -m standaloneWindows
启动命令(standalone代表着单机模式运行,非集群模式):startup.cmd -m standalone

4. yaml配置

nacos:discovery:server-addr: 127.0.0.1:8848enabled: trueautoRegister: true# 指定本项目的注册地址和端口号 这里配置的数元数据register:metadata:gRPC-port: 19090

5.Demo

5.1 配置中心简单格式获取方式

在这里插入图片描述

在这里插入图片描述

  @NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)private boolean useLocalCache;@GetMapping("getNacos")public Result getNacos() throws NacosException {return ResultGenerator.getSuccessResult(useLocalCache);}

结果:
在这里插入图片描述
在这里插入图片描述

普通方式还可以再启动类上添加注解完成

@NacosPropertySources(value = {@NacosPropertySource(dataId = "example", groupId = "TEST_GROUP", autoRefreshed = true),@NacosPropertySource(dataId = "example", autoRefreshed = true),@NacosPropertySource(dataId = "testList", autoRefreshed = true)})

5.2 获取json格式的demo

@Configuration
public class NacosConfig {@Value("${nacos.config.server-addr}")private String serverAdd;@Value("${nacos.config.namespace:}")private String namespace;@Beanpublic ConfigService configService() throws NacosException {final Properties properties = new Properties();//设置Nacos节点对应的IP地址properties.setProperty(PropertyKeyConst.SERVER_ADDR, serverAdd);//设置命名空间properties.setProperty(PropertyKeyConst.NAMESPACE, namespace);//如果开启了Nacos权限校验,设置用户名
//        properties.setProperty(PropertyKeyConst.USERNAME,"nacos");
//        properties.setProperty(PropertyKeyConst.PASSWORD,"nacos");//设置获取配置信息的轮询超时时间properties.setProperty(PropertyKeyConst.CONFIG_LONG_POLL_TIMEOUT, "3000");//设置获取配置信息失败后的重试次数properties.setProperty(PropertyKeyConst.CONFIG_RETRY_TIME, "5");//设置是否开启客户端主动拉取最新的配置信息properties.setProperty(PropertyKeyConst.MAX_RETRY, "5");//构造一个ConfigService实例ConfigService configService = NacosFactory.createConfigService(properties);return configService;}}@RestController
@RequestMapping("test")
@Slf4j
public class TestController {@Autowiredprivate ConfigService configService;@NacosValue(value = "${useLocalCache:false}", autoRefreshed = true)private boolean useLocalCache;@GetMapping("getNacos")public Result getNacos() throws NacosException {String config = configService.getConfig("testjson", "DEFAULT_GROUP", 3000);getConfig();return ResultGenerator.getSuccessResult(useLocalCache);}}

结果:
在这里插入图片描述
在这里插入图片描述

5.2 自动注册根据yaml配置

enabled: true
autoRegister: true

当然可以在启动类上添加注解
@EnableNacosDiscovery
在这里插入图片描述

http://www.zhongyajixie.com/news/43978.html

相关文章:

  • web简单网页嘉兴关键词优化报价
  • 网站平台推广语录深圳疫情防控最新消息
  • wordpress seo 模板重庆seo代理计费
  • 网站服务器维护免费网页制作平台
  • 自己建一个网站需要准备什么企业网站建设报价表
  • 学包装设计网站百度指数怎么分析
  • 科技栋梁之歌杭州网站运营十年乐云seo
  • 北京首钢建设有限公司网站域名权重查询
  • 国务院测一测可以在网站上做吗网站查询工具seo
  • 在深圳如何注册自己的公司滕州网站建设优化
  • 网上做流量对网站有什么影响郑州搜索引擎优化
  • 专业建站公司热线电话流程优化四个方法
  • 做公司网站主要需要什么百度投诉中心24人工客服电话
  • 网站建设基本流程价格手机百度app免费下载
  • 刷信誉网站制作常德seo招聘
  • wordpress https css合肥网络公司seo建站
  • 网站开发新技术新seo排名点击软件
  • 免费申请账号网站磁力云搜索引擎入口
  • 十大最好的网站如何优化培训方式
  • 做阿里巴巴网站 店铺装修免费吗培训网站制作
  • 宝安最好的网站建设打造龙头建设示范
  • 做网站店铺怎样打理网络科技公司经营范围
  • 网站内的链接怎么做的百度快速收录3元一条
  • 长沙中小企业做网站百度热词搜索指数
  • 网上注册平台怎么注册google关键词优化
  • 单页网站产品网站推广优化排名教程
  • 区块链的网站怎么做广州最新疫情通报
  • 网站如何做聚合页面太原自动seo
  • 做兼职用什么网站最好免费顶级域名注册网站
  • 建设通网站是什么性质百度竞价推广效果怎么样