注意:@LoadBalanced注解不加,Applicayion作为url将失效
(5)消费服务 package com.xm.cloud.controller; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RestController; import org.springframework.web.client.RestTemplate; @RestController public class HelloController { @Autowired private RestTemplate restTemplate; @GetMapping("/hello") public String sayHello() { return restTemplate.getForObject("http://CL-HELLO-PRODUCER/hello", String.class); } } 4.运行结果 (1)启动cl_eureka查看:localhost:7001
(2)启动提供者查看:localhost:7001
(3)启动消费者查看:localhost:8080\hello