注意,如下的Feign遇到的坑,在高版本中有些已经修复。
某些项目因为历史包袱缘由,没法进行全面升级,才须要修补这些坑。html
1.启动报错:not annotated with HTTP method type (ex. GET, POST)
错误缘由:
低版本的Feign不支持@PostMapping
解决方法:
在Feign中使用@RequestMapping,以下示:app
@FeignClient(value = "base") public interface OrderDetailService { @RequestMapping(value="/order/detail",method=RequestMethod.POST) JSONObject getOrderDetailByCdkey(@RequestParam("cdkey") String cdkey); }
2.启动报错:RequestParam.value() was empty on parameter 0
错误缘由:@RequestParam()注解内的参数不能为空
解决方法:加入具体参数,如@RequestParam("cdkey") String cdkey.net
3.启动报错:PathVariable annotation was empty on param 0.
错误缘由:@PathVariable()注解内的参数不能为空
解决方法:加入具体参数,如@PathVariable("id") String id
示例以下:code
@RequestMapping(value="/eureka/apps/{serviceName}", method=RequestMethod.GET) public String getServiceInfoByserviceName(@PathVariable("serviceName") String serviceName) ; }
相关博客:
SpringCloud Feign 踩到的坑(一)
参考资料:
https://blog.csdn.net/huaseven0527/article/details/80533983
https://blog.csdn.net/uotail/article/details/84673347htm