天天看點

springcloud feign 與 openFeign差別

1、Feign與OpenFeign的差別

1)Feign是Spring Cloud元件中一個輕量級RESTful的HTTP服務用戶端,Feign内置了Ribbon,用來做用戶端負載均衡,去調用服務注冊中心的服務。Feign的使用方式是:使用Feign的注解定義接口,調用接口,就可以調用服務注冊中心的服務。

Feign的依賴

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-feign</artifactId>
</dependency>
           

2)OpenFeign是Spring Cloud在Feign的基礎上支援了SpringMVC的注解,如@RequestMapping等等。OpenFeign的@FeignClient可以解析SpringMVC的@RequestMapping注解下的接口,并通過動态代理的方式産生實作類,實作類中.

OpenFeign的依賴

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
           

說明:

springcloud F 及F版本以上 springboot 2.0 以上基本上使用openfeign,openfeign 如果從架構結構上看就是2019年feign停更後出現版本,也可以說大多數新項目都用openfeign ,2018年以前的項目在使用feign

連結:https://www.jianshu.com/p/fc5de8218384

繼續閱讀