Using @RequestLine with Feign

I have a working Feign interface that is defined as:

@FeignClient("content-link-service")
public interface ContentLinkServiceClient {

    @RequestMapping(method = RequestMethod.GET, value = "/{trackid}/links")
    List<Link> getLinksForTrack(@PathVariable("trackid") Long trackId);

}

If I change this to use @RequestLine

@FeignClient("content-link-service")
public interface ContentLinkServiceClient {

    @RequestLine("GET /{trackid}/links")
    List<Link> getLinksForTrack(@Param("trackid") Long trackId);

}

I get an exception

Called: java.lang.IllegalStateException: the getLinksForTrack method is not annotated with the HTTP method type (for example, GET, POST)

Any ideas why?

+4
source share
2 answers

I would not expect this to work.

@RequestLineis an annotation for the main fage, but you are using Spring Cloud @FeignClient, which uses Spring MVC annotations.

+8
source

Spring Feign Contract, Spring @RequestMapping Feigns. bean feign.Contract.Default .

spring-boot ( -, Java), @Configuration, Feign:

@Bean
public Contract useFeignAnnotations() {
    return new Contract.Default();
}
+3

All Articles