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

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

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

服务调用方

示例三处有问题代码:

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

正确代码:

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

正确代码2:

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

服务提供方

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

java 复制代码
@PostMapping("/api方法名")
ResultEntity functionName(Account account, String tenantId);

正确代码2:

java 复制代码
@PostMapping("/api方法名")
ResultEntity functionName(@RequestBody Account account, String tenantId);
相关推荐
014-code4 小时前
订单超时取消与库存回滚的完整实现(延迟任务 + 状态机)
java·开发语言
java1234_小锋5 小时前
Java高频面试题:Springboot的自动配置原理?
java·spring boot·面试
末央&6 小时前
【天机论坛】项目环境搭建和数据库设计
java·数据库
枫叶落雨2226 小时前
ShardingSphere 介绍
java
花花鱼6 小时前
Spring Security 与 Spring MVC
java·spring·mvc
言慢行善7 小时前
sqlserver模糊查询问题
java·数据库·sqlserver
专吃海绵宝宝菠萝屋的派大星7 小时前
使用Dify对接自己开发的mcp
java·服务器·前端
大数据新鸟8 小时前
操作系统之虚拟内存
java·服务器·网络
Tong Z8 小时前
常见的限流算法和实现原理
java·开发语言
凭君语未可8 小时前
Java 中的实现类是什么
java·开发语言