spring-boot-autoconfigure 2.2.0 change HttpMessageConverters auto configure with condition "NoReativeWebApplicationCondition", so when use openfeign to decode response, there will throws HttpMessageConverters not available exception, could you please add a HttpMessageConverters bean auto configure in openfeign configuration?
Comment From: lin1005q
It's happended when I update spring cloud version to Hoxton.RELEASE. And Greenwich.SR4 is ok.
this is ok
<properties>
<spring.cloud.version>Greenwich.SR4</spring.cloud.version>
<spring.boot.version>2.1.9.RELEASE</spring.boot.version>
</properties>
this is error
<properties>
<spring.cloud.version>Hoxton.RELEASE</spring.cloud.version>
<spring.boot.version>2.2.1.RELEASE</spring.boot.version>
</properties>
feign.codec.DecodeException: No qualifying bean of type 'org.springframework.boot.autoconfigure.http.HttpMessageConverters' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}
Comment From: vicliu624
I am faced with the same problem with you
I have solved this problem
@Configuration
public class FeignResponseDecoderConfig {
@Bean
public Decoder feignDecoder() {
ObjectFactory<HttpMessageConverters> messageConverters = () -> {
HttpMessageConverters converters = new HttpMessageConverters();
return converters;
};
return new SpringDecoder(messageConverters);
}
}
Comment From: spencergibb
The above is a workaround. HttpMessageConverter's are blocking and will cause a webflux application to break. HttpMessageReader is the non-blocking equivalent.
Comment From: AlexTo
@spencergibb can you give some code example? I can't get feign to work even with @vicliu624 code
Comment From: AlexTo
Ah ok, @vicliu624 code does work but I have to declare both Encoder and Decoder like this
private ObjectFactory<HttpMessageConverters> messageConverters = HttpMessageConverters::new;
@Bean
Encoder feignFormEncoder() {
return new SpringFormEncoder(new SpringEncoder(messageConverters));
}
@Bean
Decoder feignFormDecoder() {
return new SpringDecoder(messageConverters);
}
}
Comment From: rainmanhhh
5 months passed. any progress?
Comment From: spencergibb
No
Comment From: thewaychung
Using above workaround would cause performance issue: response time increase from 7ms to 30ms on the same FeignClient request path.
Comment From: Sbwillbealier
Ah ok, @vicliu624 code does work but I have to declare both Encoder and Decoder like this
``` private ObjectFactory
messageConverters = HttpMessageConverters::new; @Bean Encoder feignFormEncoder() { return new SpringFormEncoder(new SpringEncoder(messageConverters)); } @Bean Decoder feignFormDecoder() { return new SpringDecoder(messageConverters); }} ```
I use the following code to solve "feign.codec.EncodeException: ":
```
private ObjectFactory
/**
* @return
*/
@Bean
Encoder feignEncoder() {
return new SpringEncoder(messageConverters);
}
/**
* @return
*/
@Bean
Decoder feignDecoder() {
return new SpringDecoder(messageConverters);
}
```
Comment From: fanticat
5 months passed. any progress?
I have replaced the openfeign for reactive feign which is not blocking, it's working fine for me.
Comment From: OlgaMaciaszek
WebFlux support in SC OF is not planned. For reactive stack, we suggest using Spring Interface Clients instead. See docs: https://docs.spring.io/spring-cloud-openfeign/reference/4.2-SNAPSHOT/spring-cloud-openfeign.html#reactive-support . Closing as not planned.