12 feign.FeignException: status

2019-01-21  本文已影响11人  滔滔逐浪

在公司的一个spring cloud 项目中,用feign client 调用服务遇到一个404问题


13423234-e1bff656f68a0671.png

原服务提供者:

  @RequestMapping(value="/index",method= RequestMethod.GET)
  public String index(String date) {
      return uv.index(date);
  }

原feign client 调用方:

@FeignClient(value = "horus-zuul-server")
public interface UvInfo{
    @RequestMapping(value = "/uv/getUvCount", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
    String index(String date);



经过分析 发现是参数没有传过去 参数传到控制器端为null

解决方法:

参考网上思路 需要加上requestparam修饰,具体修改如下:

提供者:


  @RequestMapping(value="/index",method= RequestMethod.GET)
  public String index(@RequestParam  String date) {
      return uv.index(date);
  }


feign 调用方:


@FeignClient(value = "horus-zuul-server")
public interface UvInfo{
    @RequestMapping(value = "/uv/index", method = RequestMethod.GET, produces = "application/json; charset=UTF-8")
    String index(@RequestParam("date") String date);


上一篇 下一篇

猜你喜欢

热点阅读