Feign是一种新的使用http进行远程调用的方式。
1)使用方法:在启动类书写一个方法,然后通过url在service中进行调用
String url = "http://userservice/user/" + order.getUserId();
User user = restTemplate.getForObject(url, User.class);
1)是一种申明式的http客户端,作用是帮助我们优雅实现http请求的发送,解决上面提到的问题。
2) 实现逻辑还是差不多的,都是为了生成一个url进行远程调用。只不过在Feign中,采用申明式结构进行URL的拆分再组装。
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
因篇幅问题不能全部显示,请点此查看更多更全内容