在Feign中使用@RequestLine [英] Using @RequestLine with Feign

查看:1295
本文介绍了在Feign中使用@RequestLine的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个有效的Feign接口,定义为:

I have a working Feign interface defined as:

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

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

}

如果我将其更改为使用@RequestLine

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);

}

我得到了例外

由以下原因引起:java.lang.IllegalStateException:方法getLinksForTrack没有使用HTTP方法类型(例如GET,POST)进行注释

Caused by: java.lang.IllegalStateException: Method getLinksForTrack not annotated with HTTP method type (ex. GET, POST)

有什么想法吗?

推荐答案

我不希望这能起作用.

@RequestLine是Feign的核心注释,但是您正在使用使用Spring MVC注释的Spring Cloud @FeignClient.

@RequestLine is a core Feign annotation, but you are using the Spring Cloud @FeignClient which uses Spring MVC annotations.

这篇关于在Feign中使用@RequestLine的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆