Spring Cloud Feign简介
Spring Cloud官方原文:
A central concept in Spring Cloud’s Feign support is that of the named client. Each feign client is part of an ensemble of components that work together to contact a remote server on demand, and the ensemble has a name that you give it as an application developer using the
@FeignClient
annotation. Spring Cloud creates a new ensemble as anApplicationContext
on demand for each named client usingFeignClientsConfiguration
. This contains (amongst other things) anfeign.Decoder
, afeign.Encoder
, and afeign.Contract
.Spring Cloud lets you take full control of the feign client by declaring additional configuration (on top of the
FeignClientsConfiguration
) using@FeignClient
.
翻译:
Spring Cloud的Feign支持中的一个中心概念是命名的客户端。 每个feign客户端都是组件的一部分,这些组件是按需联系远程服务器的组件的一部分,并且集合有一个名称,您可以使用@FeignClient注释将其作为应用程序开发人员提供。 Spring Cloud使用FeignClientsConfiguration
创建一个新的集合,作为每个指定客户端的ApplicationContext
。 这包含(其中包括)feign.Decoder
,feign.Encoder
和feign.Contract
。
通过使用@FeignClient
声明额外的配置(在FeignClientsConfiguration
之上),Spring Cloud可让您完全控制Feign客户端。
覆盖Feign的默认配置
定义Feign客户端接口
@FeignClient(name = "microservice-springcloud-user",configuration = MyConfiguration.class)
public