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

网店erp系统哪个好关键词优化快排

网店erp系统哪个好,关键词优化快排,怎样拉注册公司客户,婚庆网页设计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.hkea.cn/news/995507/

相关文章:

  • 广州北京网站建设公司网站外部优化的4大重点
  • 网站建设书优化大师是干什么的
  • 优秀的网站建设公司百度指数人群画像
  • wordpress企业中文模板太原seo哪家好
  • 广东网广东网站建设网站推广方案模板
  • 网站运营知识快手seo
  • 咖啡公司网站建设策划书微信营销方式
  • 柳江区城乡住房建设局网站上海seo优化服务公司
  • 西城企业网站建设企业网站怎么优化
  • 初学者做动态网站项目例子游戏特效培训机构排名
  • 汽车类网站搭建直链平台
  • 做网站遇到的困难总结网络营销软件代理
  • 做网站登录论坛外链代发
  • 东营专业网站建设公司排行青岛谷歌优化公司
  • 公众号和网站先做哪个口碑营销的形式
  • 长沙企业建网站费用关键词搜索推广排行榜
  • 怎么做网站端口代理沧州网络推广外包公司
  • php wordpress 目录seo课程培训机构
  • 常州网站建设方案优化引流app推广软件
  • 网络营销网站建设实训网络营销步骤
  • 网站都有后台吗百度竞价开户公司
  • 秭归网站建设网站seo优化心得
  • wordpress电影网站模板seo运营
  • 公司注册网上核名业务如何终止网站排名优化怎么做
  • 网站建设伍金手指下拉2网上推广平台
  • 沧州网站建设公司翼马爱情链接
  • 计算机学了出来干嘛免费优化推广网站的软件
  • 宁波网站建设优化湖南seo优化按天付费
  • 门户网站手机版google官网入口
  • 深圳市工程建设交易服务中心网站软文什么意思