在整合spring cloud geateway 时,调用了feign接口,报错No qualifying bean of type 'org.springframework.boot.autoconfigure.http.HttpMessageConverters' available
报错信息
feign.codec.EncodeException: No qualifying bean of type 'org.springframework.boot.autoconfigure.http.HttpMessageConverters' available: expected at least 1 bean which qualifies as autowire candidate. Dependency annotations:
错误原因
Spring Cloud Gateway是基于WebFlux的,是ReactiveWeb,所以HttpMessageConverters不会自动注入。在gateway服务中配置以下Bean,即可解决。
@Configuration
public class FeignConfig {
@Bean
@ConditionalOnMissingBean
public HttpMessageConverters messageConverters(ObjectProvider<HttpMessageConverter<?>> converters) {
return new HttpMessageConverters(converters.orderedStream().collect(Collectors.toList()));
}
}
标签:available,feign,HttpMessageConverters,No,qualifying,bean,报错
From: https://www.cnblogs.com/luyifo/p/18152429