【发布时间】:2019-04-19 18:40:44
【问题描述】:
我不知道自己做错了什么,但是每次 feign 客户端都将声明为 get 的方法转换为 post 类型。
@FeignClient(name = "my-service", url = "http://localhost:8114", path = "service")
public interface MyServiceClient {
@RequestMapping(method = GET, value = "/clients")
Client getClients(@QueryMap MyPojo pojo);
}
@Getter
@Setter
public class MyPojo {
@NotNull
private String someValue;
@NotNull
private SomeEnum someEnum;
}
此设置应解析为以下请求:GET http://localhost:8114/service/clients?someValue=foo&someEnum=bar
但每次我得到这个结果时:
{
"timestamp": 1542378765498,
"status": 405,
"error": "Method Not Allowed",
"exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
"message": "Request method 'POST' not supported",
"path": "/service/clients"
}
但是当我这样做时它工作正常:
@RequestMapping(method = GET, value = "/clients?someValue=foo&someEnum=bar")
Client getClients();
我正在开发包含feign-core/sl4fj/hystrix/ 9.3.1 版本的spring-cloud-starter-feign 1.2.7.RELASE 版本,但我也在10.1.0 版本上对其进行了测试,结果相同。
我应该怎么做才能解决这个问题?
【问题讨论】:
标签: java spring spring-cloud-feign feign