我有一个工作的 Feign 接口(interface)定义为:
@FeignClient("content-link-service")
public interface ContentLinkServiceClient {
@RequestMapping(method = RequestMethod.GET, value = "/{trackid}/links")
List<Link> getLinksForTrack(@PathVariable("trackid") Long trackId);
}
如果我将其更改为使用@RequestLine
@FeignClient("content-link-service")
public interface ContentLinkServiceClient {
@RequestLine("GET /{trackid}/links")
List<Link> getLinksForTrack(@Param("trackid") Long trackId);
}
我得到异常
Caused by: java.lang.IllegalStateException: Method getLinksForTrack not annotated with HTTP method type (ex. GET, POST)
有什么想法吗?
最佳答案
我没想到这会奏效。
@RequestLine
是核心 Feign 注释,但您使用的是 Spring Cloud @FeignClient
,它使用 Spring MVC 注释。
关于java - 将 @RequestLine 与 Feign 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29985205/