Java 【dubbo rpc改feign调用】解决调用服务提供方无法传递完整参数问题

dubbo rpc改feign调用,feign调用接口异常统一处理


【框架改造问题点记录,dubbo改为spring cloud alibaba】
【第二篇】feign接口异常解决
【描述】多参数情况下,调用服务提供方无法传递完整参数、改@SpringQueryMap原因是会将实体自动拆分为拼接参数。目前只遇到多参数:实体和单参数情况,持续更新…

服务调用方

示例三处有问题代码:

@RequestMapping(value = "api相对路径", method = RequestMethod.POST)
ResultEntity functionName(@RequestBody Account account, @RequestParam("tenant") String tenant);
@RequestMapping(value = "api相对路径", method = RequestMethod.POST)
ResultEntity functionName(Account account, @RequestParam("tenant") String tenant);
@RequestMapping(value = "api相对路径", method = RequestMethod.GET)
ResultEntity functionName(Account account, @RequestParam("tenant") String tenant);

正确代码:

@RequestMapping(value = "api相对路径", method = RequestMethod.POST)
ResultEntity functionName(@SpringQueryMap Account account, @RequestParam("tenant") String tenant);

正确代码2:

@RequestMapping(value = "api相对路径", method = RequestMethod.POST)
ResultEntity functionName(@RequestBody Account account, @RequestParam("tenant") String tenant);

服务提供方

注意请求方式保持一致即可:

@PostMapping("/api方法名")
ResultEntity functionName(Account account, String tenantId);

正确代码2:

@PostMapping("/api方法名")
ResultEntity functionName(@RequestBody Account account, String tenantId);

猜你喜欢

转载自blog.csdn.net/qq_16843563/article/details/131722297
今日推荐