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

模板网站的弊端在哪wordpress快速制作app

模板网站的弊端在哪,wordpress快速制作app,广西和住房城乡建设厅网站,辽宁沈阳网站建设1.概要 1.1 说明 这个是在前一个测试上的修改,所以这里只体现修改的内容。前一个测试的地址:检查实验 spring cloud nacos nacos-server-2.3.0-CSDN博客 1.2 记忆要点 1.2.1 引入对象 Autowired DiscoveryClient discoveryClient; 1.2.2 获取服务实…

1.概要

1.1 说明

这个是在前一个测试上的修改,所以这里只体现修改的内容。前一个测试的地址:检查实验 spring cloud nacos nacos-server-2.3.0-CSDN博客

1.2 记忆要点

1.2.1 引入对象

@Autowired
DiscoveryClient discoveryClient;

1.2.2 获取服务实例 

List<ServiceInstance> serviceInstances = discoveryClient.getInstances("server3");
int index = new Random().nextInt(serviceInstances.size());
ServiceInstance serviceInstance = serviceInstances.get(index);

1.2.3 利用服务实例调用函数 

String url = "http://"+serviceInstance.getHost()+":"+serviceInstance.getPort()+"/fun";

2.代码变更

package com.xjc.springcloundtest;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;import java.util.List;
import java.util.Random;@RestController
public class TestController2 {@AutowiredDiscoveryClient discoveryClient;//@Autowired//FenTest fenTest;@AutowiredRestTemplate restTemplate;@RequestMapping("/fun2")public String fun2(){List<ServiceInstance> serviceInstances = discoveryClient.getInstances("server3");int index = new Random().nextInt(serviceInstances.size());ServiceInstance serviceInstance = serviceInstances.get(index);//String url = "http://localhost:8080/fun";//String url = "http://server3/fun";String url = "http://"+serviceInstance.getHost()+":"+serviceInstance.getPort()+"/fun";//String ret = fenTest.fun();String ret = restTemplate.getForObject(url,String.class);return "函数2"+ret;}
}

3 运行结果

http://www.yayakq.cn/news/790051/

相关文章:

  • 苏州网络自学网站建设深圳建设交易平台官网
  • 想办个网站怎么做微信推广软件有哪些
  • 爱站网ip反域名查询快手seo
  • 建设通网站公路查询购物商城网站源码
  • 加强政务门户网站建设电子商务网站设计总结
  • 网站开发 哪个工具更快网站建设用什么语言
  • 学做热干面网站wordpress更新服务器
  • lamp网站开发架构经验wordpress缩进element
  • 手机响应式网站开发模板之家移动互联网应用的使用情况
  • 做网站如何选域名swoole 网站开发
  • 法与家国建设征文网站怎么做自己的网站logo
  • 台州中兴建设咨询有限公司网站网页管理系统怎么制作
  • 网站建立需要哪些材料淮安网站seo
  • 北京中天人建设工程有限公司网站如何套模板做网站
  • 织梦网站0day漏洞最新实时大数据
  • 用html做的网站步骤媒体发稿
  • 网站修改关键词不收录wordpress 两边
  • iis默认网站路径辽宁省建设厅网站中级职称公示
  • 杭州做网站的好公司广州花都网站建设
  • 企业网站模板购买wordpress爆力
  • 网站开发软件教程速冻蔬菜做哪个国际网站好
  • 网站前端设计理念大型电子商务网站建设公司
  • 网站精神文明建设专栏生态养殖网站模板
  • 设计网站的结构时下面哪个方法不好wordpress centos 7
  • 做淘宝客网站需要做后台吗wordpress 单页模板
  • 网站建设及目标网站建立公司四川
  • 做展示网站步骤小区服务网站怎么做
  • 北京海淀区建设局网站专做艺术圈的网站
  • 东光网站建设漳州网站建设到博大
  • 做美食视频的网站有哪些整站seo运营