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

广告设计接单网站自己建设一个网站

广告设计接单网站,自己建设一个网站,网易企业邮箱登录口,电脑版网页入口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/898644/

相关文章:

  • 个人网站空间申请嘉兴网站优化
  • 英文网站建设官网营销网站模板下载
  • 网站建设的申请短视频营销方式有哪些
  • 杭州微跑网站建设公司如何推广小程序平台
  • 网站多语切换怎么做衡水公司做网站
  • 成都网站建设哪家售后好小程序模板大全
  • txt网站推荐四川华泰建设集团网站
  • 租车网站制作南京网站建设流程
  • wordpress可以建站吗钢铁网站哪家做的好
  • 网站开发html php网站建设的功能和定位
  • 怎么免费建立一个网站热搜榜上2023年热搜
  • 清远做网站的公司php js做网站
  • 仿皮皮淘网站开发全程培训平湖市网站建设
  • 网站建设费的摊销期做网站网络公司无收入
  • 响应网站 整屏手机兼职可以做什么
  • 做网站的好项目网站生成app
  • 雁塔网站建设职高的电子商务主要学什么
  • 汽车网站建设论文网站什么认证对做电商好
  • 湛江自助建站软件o2o网站建设服务
  • 网站诚信建设上海 网站设计 公司
  • 网站的域名在哪里看设计师网站prinest
  • 百捷网站建设工资wordpress 原创模板
  • 网站与个人网站陕西省交通建设网站
  • 做网站资源管理是dw做的网站怎么让别人看到
  • 网站开发需要2个月吗做设计图的软件
  • 电影订票网站开发wordpress 微博同步插件
  • 怎么注销建设银行网站用户经典软文案例和扶贫农产品软文
  • 仲恺建设局网站wordpress 4.5 浏览器ie8.0
  • 网站一般怎么推广百度推广开户需要多少钱
  • 成都APP 微网站开发sql网站模板