feign自带的请求,不支持复杂的对象作为get请求的参数,会自动转成post,如果想要使用get请求传递自定义对象的话,就要做一些改动。
1、引入以下两个依赖
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>com.netflix.feign</groupId>
<artifactId>feign-httpclient</artifactId>
<version>8.18.0</version>
</dependency>
2、java代码加上consumes =MediaType.APPLICATION_JSON_VALUE
@RequestMapping(value ="xxx/xxx",method =RequestMethod.GET,consumes =MediaType.APPLICATION_JSON_VALUE)
Payload> findPage(XXXXObj query);
3、配置文件加上feign.httpclient,enabled =true
网友评论