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);
相关推荐
程序员清风2 小时前
程序员兼职必看:靠谱软件外包平台挑选指南与避坑清单!
java·后端·面试
皮皮林5513 小时前
利用闲置 Mac 从零部署 OpenClaw 教程 !
java
华仔啊8 小时前
挖到了 1 个 Java 小特性:var,用完就回不去了
java·后端
SimonKing8 小时前
SpringBoot整合秘笈:让Mybatis用上Calcite,实现统一SQL查询
java·后端·程序员
日月云棠1 天前
各版本JDK对比:JDK 25 特性详解
java
用户8307196840821 天前
Spring Boot 项目中日期处理的最佳实践
java·spring boot
JavaGuide1 天前
Claude Opus 4.6 真的用不起了!我换成了国产 M2.5,实测真香!!
java·spring·ai·claude code
IT探险家1 天前
Java 基本数据类型:8 种原始类型 + 数组 + 6 个新手必踩的坑
java
花花无缺1 天前
搞懂new 关键字(构造函数)和 .builder() 模式(建造者模式)创建对象
java
用户908324602731 天前
Spring Boot + MyBatis-Plus 多租户实战:从数据隔离到权限控制的完整方案
java·后端