Using @RequestLine with Feign

后端 未结 3 1696
北恋
北恋 2021-02-05 13:03

I have a working Feign interface defined as:

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

    @RequestMapping(method = Req         


        
3条回答
  •  傲寒
    傲寒 (楼主)
    2021-02-05 13:26

    Your @RequestMapping value looks ok, but you're likely should consider slightly rewriting it:

     @GetMapping(value = "/{trackid}/links")
     List getLinksForTrack(@PathVariable(name = "trackid") Long trackId);
    

    Btw I did not succeeded with getting @RequestLine to work due to same error as yours.

    Also for @ReactiveFeignClients Contract.Default() yields to following errors:

    java.lang.IllegalStateException: Method MyClient#doStuff(String,String) not annotated with HTTP method type (ex. GET, POST)
    Warnings:
    - Class MyClient has annotations [Component, ReactiveFeignClient, Metadata] that are not used by contract Default
    - Method doStuff has an annotation GetMapping that is not used by contract Default
    

    and should be fixed like:

    var MyClient = WebReactiveFeign.builder()
            .contract(new ReactiveContract(new SpringMvcContract()))
            .target(MyClient, "http://example.com")
    

提交回复
热议问题