feignCould not write request: no suitable HttpMessageConverter found for request type
Posted 盖丽男
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了feignCould not write request: no suitable HttpMessageConverter found for request type相关的知识,希望对你有一定的参考价值。
背景
spring程序,使用的feign调用其他服务,结果抛异常:
"Could not write request: no suitable HttpMessageConverter found for request type [com.ekeguan.tradefacade.pojo.req.phpParams] and content type [application/x-www-form-urlencoded]"}
feign.codec.EncodeException: Could not write request: no suitable HttpMessageConverter found for request type [com.ekeguan.tradefacade.pojo.req.PhpParams] and content type [application/x-www-form-urlencoded]
at org.springframework.cloud.openfeign.support.SpringEncoder.encode(SpringEncoder.java:151)
at feign.ReflectiveFeign$BuildEncodedTemplateFromArgs.resolve(ReflectiveFeign.java:380)
at feign.ReflectiveFeign$BuildTemplateByResolvingArgs.create(ReflectiveFeign.java:232)
看一下报错地方的代码:
@RequestMapping(value = "/api/distribute/get"
, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE
, method = RequestMethod.POST)
ApiResponse getOrderExpressList(PhpParams params);
解决方法:
@Bean
Encoder feignFormEncoder(ObjectFactory<HttpMessageConverters> converters) {
return new SpringFormEncoder(new SpringEncoder(converters));
}
以上是关于feignCould not write request: no suitable HttpMessageConverter found for request type的主要内容,如果未能解决你的问题,请参考以下文章
postgresql 日志报错could not write to log file: No space left on device,could not write lock file "
文件打开时出现“QIODevice::write: device not open”
TypeError: write() argument must be str, not bytes
Python_异常:TypeError: write() argument must be str, not list