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);
相关推荐
RainbowSea6 小时前
12. LangChain4j + 向量数据库操作详细说明
java·langchain·ai编程
RainbowSea6 小时前
11. LangChain4j + Tools(Function Calling)的使用详细说明
java·langchain·ai编程
考虑考虑10 小时前
Jpa使用union all
java·spring boot·后端
用户37215742613510 小时前
Java 实现 Excel 与 TXT 文本高效互转
java
浮游本尊11 小时前
Java学习第22天 - 云原生与容器化
java
渣哥13 小时前
原来 Java 里线程安全集合有这么多种
java
间彧13 小时前
Spring Boot集成Spring Security完整指南
java
间彧14 小时前
Spring Secutiy基本原理及工作流程
java
Java水解15 小时前
JAVA经典面试题附答案(持续更新版)
java·后端·面试
洛小豆17 小时前
在Java中,Integer.parseInt和Integer.valueOf有什么区别
java·后端·面试