feign踩过的坑-post not support

如下定义了一个错误的get请求方法

public class HelloDao {
    @RequestMapping(value="/hello",method= RequestMethod.GET)
    public String sayHello(Integer id);
}

如果feign代理的是get请求,则每个参数必须带上@RequestParam,否则会报post not support!

服务端写法如下:

@RestController
public class HelloController {
    @RequestMapping(value="/hello",method= RequestMethod.GET)
    public String sayHello(@RequestParam("id") Integer id){
        return "id:"+id;
    }
}

正确的调用方法如下

@FeignClient("xxxxx")
public class HelloDao {
    @RequestMapping(value="/hello",method= RequestMethod.GET)
    public String sayHello(@RequestParam("id") Integer id);
}

你可能感兴趣的:(框架入门总结,环境搭建)