SPring Coud Feign Post调用参数是pojo类型的方法

微服务之前若想用feign通过Post请求调用服务端接口,且参数是POJO类型的,则在定义调用接口的方法注解上需要多加一个consumes = "application/json",如果没有这个参数,会调用失败
示例:
我在当前模块 需要调用告警模块的某一插入服务,则feignClient文件定义如下:
@FeignClient(name = "ccsp-alarm", fallback = AlarmContactFeginFallback.class)

public interface AlarmContactFeignClient {



    
    @RequestMapping(method= RequestMethod.POST,value="/alarms/users/contactors",consumes = "application/json")

    InvokeResult insertByUserInfo(@RequestBody List userSysDtos);

}


猜你喜欢

转载自blog.csdn.net/liubingyu12345/article/details/78192764