Update: 集成 Feign Client 和 Ribbon
This commit is contained in:
+3
-2
@@ -1,5 +1,6 @@
|
||||
package cn.hezhaohui.serviceconsumer.controller;
|
||||
|
||||
import cn.hezhaohui.serviceconsumer.client.ServiceProducerClient;
|
||||
import jakarta.annotation.Resource;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
@@ -11,11 +12,11 @@ import org.springframework.web.client.RestTemplate;
|
||||
public class ConsumeController {
|
||||
|
||||
@Resource
|
||||
private RestTemplate restTemplate;
|
||||
private ServiceProducerClient serviceProducerClient;
|
||||
|
||||
@GetMapping("/print")
|
||||
public String print() {
|
||||
String number = restTemplate.getForObject("http://service-producer/api/number", String.class);
|
||||
String number = serviceProducerClient.getNumber();
|
||||
return "[Generate]: " + number;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user