1、Feign與OpenFeign的區(qū)別
- 1)Feign是Spring Cloud組件中一個輕量級RESTful的HTTP服務客戶端,Feign內置了Ribbon,用來做客戶端負載均衡,去調用服務注冊中心的服務。Feign的使用方式是:使用Feign的注解定義接口,調用接口,就可以調用服務注冊中心的服務。
Feign的依賴
1 <dependency>
2 <groupId>org.springframework.cloud</groupId>
3 <artifactId>spring-cloud-starter-feign</artifactId>
4 </dependency>
- 2)OpenFeign是Spring Cloud在Feign的基礎上支持了SpringMVC的注解,如@RequestMapping等等。OpenFeign的@FeignClient可以解析SpringMVC的@RequestMapping注解下的接口,并通過動態(tài)代理的方式產生實現類,實現類中.
OpenFeign的依賴
1 <dependency>
2 <groupId>org.springframework.cloud</groupId>
3 <artifactId>spring-cloud-starter-openfeign</artifactId>
4 </dependency>
說明:
springcloud F 及F版本以上 springboot 2.0 以上基本上使用openfeign,openfeign 如果從框架結構上看就是2019年feign停更后出現版本,也可以說大多數新項目都用openfeign ,2018年以前的項目在使用feign