就目前而言的话,微服务的之间的调用方式有两种:
第一种:Ribbon + restTemplate
public String consumer() {
return restTemplate.getForObject("http://eureka-client/dc", String.class);
}
第二种:Fegin
@FeignClient(value = "eureka-client")
public interface DcClientService {
@GetMapping("/dc")
String consumer();
}
还要注意一点其实Fegin中也使用了Ribbon!
本文探讨了微服务架构中两种常见的服务间调用方式:Ribbon+restTemplate与Fegin。通过具体代码示例,展示了如何使用这两种方法实现服务调用,并指出Fegin内部亦依赖于Ribbon。
1万+

被折叠的 条评论
为什么被折叠?



