feign.FeignException: status 404 reading xxService#xxmethod(String)

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

原服务提供者: 

  @RequestMapping(value="/getUvCount",method= RequestMethod.GET)
  public String getUvCount(String date) {
      return uv.getUvCount(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 getUvCount(String date);

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

解决方法:

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

提供者: 

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

feign 调用方:

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

你可能感兴趣的:(java,springcloud)