Java [dubbo rpc changed to feign call] Solve the problem that the calling service provider cannot pass complete parameters

Dubbo rpc is changed to feign call, and feign call interface exceptions are handled uniformly


[Record of problem points in framework transformation, dubbo changed to spring cloud alibaba]
[Part 2] Feign interface exception solution
[Description] In the case of multiple parameters, the calling service provider cannot pass complete parameters. The reason for changing @SpringQueryMap is that entities will be automatically split into concatenated parameters. At present, only multi-parameters are encountered: entities and single-parameter cases, continuously updated...

service caller

Example three problematic codes:

@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);

Correct code:

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

Correct code 2:

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

service provider

Note that the request method should be consistent:

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

Correct code 2:

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

Guess you like

Origin blog.csdn.net/qq_16843563/article/details/131722297