I don't know what I'm doing wrong, but each time feign client converts method declared as get to post type.
@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;
}
This setup should be resolved to this request:
GET http://localhost:8114/service/clients?someValue=foo&someEnum=bar
But each time I'm getting this result:
{
"timestamp": 1542378765498,
"status": 405,
"error": "Method Not Allowed",
"exception": "org.springframework.web.HttpRequestMethodNotSupportedException",
"message": "Request method 'POST' not supported",
"path": "/service/clients"
}
However it works fine when I do it in this way:
@RequestMapping(method = GET, value = "/clients?someValue=foo&someEnum=bar")
Client getClients();
I'm working on spring-cloud-starter-feign 1.2.7.RELASE
version which contains, feign-core/sl4fj/hystrix/ 9.3.1
version, but I also tested it on 10.1.0 version, with this same result.
What should I do to resolve this issue?
In my project I use spring-cloud-dependencies
with Camden.SR7
version which contains 9.3.1
feign version, at current time the newest version is Finchley.RELEASE
which contains feign 9.7
and I see it's dedicated for spring-boot 2.x.x
, but my whole infrastructure (config/eureka server) runs on 1.5.x
so it produces next issues. I took a look at github documentation for feign, and I discovered @Param
annotation might be helpful, but when I use it in method with 3 arguments, it throws exception Method has too many Body parameters~
. Finally annotation @RequestParam
from spring works as workaround, but I didn't found any source of information that we can combine these annotations.
@RequestMapping(method = GET, value = "/clients")
Client getClients(@RequestParam("someValue") String someValue, @RequestParam("someEnum") String someEnum);
I didn't found spring-cloud-dependencies
version which contains 9.7
feign and it's dedicated for spring-boot 1.5.x
applications.