【feign】Could not write request: no suitable HttpMessageConverter found for request type

简介: 【feign】Could 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));
    }
目录
相关文章
|
2月前
|
应用服务中间件 Apache
springmvc中报错Request processing failed;
springmvc中报错Request processing failed;
13 0
|
25天前
|
应用服务中间件 Apache
消息 Request method ‘POST‘ not supported
消息 Request method ‘POST‘ not supported
|
7月前
|
Java
【Java异常】Feign常见的坑总结之一:Method Not Allowed“,“message“:“Request method ‘POST‘ not supported“,“path“:“/*
【Java异常】Feign常见的坑总结之一:Method Not Allowed“,“message“:“Request method ‘POST‘ not supported“,“path“:“/*
97 0
|
9月前
|
人工智能 Java
Required request body is missing
Required request body is missing
|
9月前
|
前端开发 数据库
Failed to load response dataNo data found for resource with given identifier
Failed to load response dataNo data found for resource with given identifier
1049 0
|
JSON 数据格式
Required request body is missing:415
Required request body is missing:415
Required request body is missing:415
|
Java Android开发
Bad method handle type 7异常解决
在利用androidx版本写demo时,在添加了一些依赖后,遇到了`java.lang.ClassNotFoundException`bug,这就很奇怪了,我就添加rxjava3的依赖,就给我报这个错误。
|
Java Spring
springmvc:405 request method post not supported
springmvc:405 request method post not supported
131 0
|
SQL JSON 前端开发
SpringMVC:400 Bad Request
SpringMVC:400 Bad Request
107 0
|
应用服务中间件
returned a response status of 405 Method Not Allowed
returned a response status of 405 Method Not Allowed
returned a response status of 405 Method Not Allowed