Feign 报错:Request method 'POST' not supported

如果Fegin代理的是get请求,那么请求参数必须带上@RequestParam 或@RequestBody

错误:

1
2
3
4
5
6
@FeignClient("dashboard")
public interface DashboardClient {

@GetMapping("projects/getApiKeyByProjectId")
String getApiKeyByProjectId(Integer projectId);
}

正确:

1
2
3
4
5
6
@FeignClient("dashboard")
public interface DashboardClient {

@GetMapping("projects/getApiKeyByProjectId")
String getApiKeyByProjectId(@RequestParam Integer projectId);
}
分享到 评论