diff --git a/docs/src/main/asciidoc/spring-cloud-openfeign.adoc b/docs/src/main/asciidoc/spring-cloud-openfeign.adoc index befcb323..8487e35b 100644 --- a/docs/src/main/asciidoc/spring-cloud-openfeign.adoc +++ b/docs/src/main/asciidoc/spring-cloud-openfeign.adoc @@ -124,7 +124,7 @@ NOTE: `spring-cloud-starter-openfeign` contains both `spring-cloud-starter-netfl The OkHttpClient and ApacheHttpClient feign clients can be used by setting `feign.okhttp.enabled` or `feign.httpclient.enabled` to `true`, respectively, and having them on the classpath. You can customize the HTTP client used by providing a bean of either `org.apache.http.impl.client.CloseableHttpClient` when using Apache or `okhttp3.OkHttpClient` when using OK HTTP. -Spring Cloud Netflix _does not_ provide the following beans by default for feign, but still looks up beans of these types from the application context to create the feign client: +Spring Cloud OpenFeign _does not_ provide the following beans by default for feign, but still looks up beans of these types from the application context to create the feign client: * `Logger.Level` * `Retryer` @@ -238,6 +238,29 @@ public interface BarClient { } ---- +It is also possible to configure FeignClient not to inherit beans from the parent context. +You can do this by overriding the `inheritParentConfiguration()` in a `FeignClientConfigurer` +bean to return `false`: + +[source,java,indent=0] +---- +@Configuration +public class CustomConfiguration{ + +@Bean +public FeignClientConfigurer feignClientConfigurer() { + return new FeignClientConfigurer() { + + @Override + public boolean inheritParentConfiguration() { + return false; + } + }; + + } +} +---- + === Creating Feign Clients Manually In some cases it might be necessary to customize your Feign Clients in a way that is not @@ -283,6 +306,9 @@ NOTE: The Feign `Contract` object defines what annotations and values are valid autowired `Contract` bean provides supports for SpringMVC annotations, instead of the default Feign native annotations. +You can also use the `Builder`to configure FeignClient not to inherit beans from the parent context. +You can do this by overriding calling `inheritParentContext(false)` on the `Builder`. + [[spring-cloud-feign-hystrix]] === Feign Hystrix Support diff --git a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingConfigurerTest.java b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingConfigurerTest.java index 8089ea27..5b82ddf0 100644 --- a/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingConfigurerTest.java +++ b/spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/FeignClientUsingConfigurerTest.java @@ -87,7 +87,8 @@ public class FeignClientUsingConfigurerTest { "requestInterceptors"); assertThat(interceptors).as("interceptors not set").isEmpty(); - assertThat(factoryBean.isInheritParentContext()).as("is inheriting from parent configuration").isFalse(); + assertThat(factoryBean.isInheritParentContext()) + .as("is inheriting from parent configuration").isFalse(); } @Test