SpringCloud使用Feign调用其他客户端带参数的接口,传入参数为null或报错status 405 reading IndexService#del(Integer); 

第一种方法:

如果你的API为Restful 方式的可以在Client接口参数中加注解@PathVariable

@FeignClient(name = "PRODUCT")
@Component
public interface ProductClient {

    @PostMapping("/product/getMsgByGet/{a}")
    String getMsg(@PathVariable("a") String a);

}

第二种方法:

不是Restful形式的API 在Client接口参数加注解@ReuqstParam

@FeignClient(name = "PRODUCT")
@Component
public interface ProductClient {
    @PostMapping("/product/getMsgByGet")
    String getMsg(@RequestParam String a);
}

不加这两个注解的话目标服务可能会无法识别参数,造成错误。

相关文章:

  • 2023-01-31
  • 2022-12-23
  • 2021-07-11
  • 2022-12-23
  • 2022-12-23
  • 2021-07-31
  • 2021-12-26
  • 2021-04-10
猜你喜欢
  • 2022-01-04
  • 2022-12-23
  • 2022-02-17
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
相关资源
相似解决方案