SpringCloud Feign报错:Method has too many Body parameters
1、feign多参数问题
1.1GET方式
错误写法
@RequestMapping(value="/test", method=RequestMethod.GET)
Model test(final String name, final int age);
启动服务的时候,会报如下异常:
Caused by: java.lang.IllegalStateException: Method has too many Body parameters: public abstract com.chhliu.springboot.restful.vo.User com.chhliu.springboot.restful.feignclient.UserFeignClient.findByUsername(java.lang.String,java.lang.String)
异常原因:当使用Feign时,如果发送的是get请求,那么需要在请求参数前加上@RequestParam注解修饰,Controller里面可以不加该注解修饰。
正确写法
@RequestMapping(value="/test", method=RequestMethod.GET)
Model test(@RequestParam("name") final String name,@RequestParam("age") final int age);
1.1POST方式
错误写法
public int save(@RequestBody final Person p, @RequestBody final UserModel user);
feign中你可以有多个@RequestParam,但只能有不超过一个@RequestBody。
正确写法
public int save(@RequestBody final Person p,@RequestParam("userId") String userId,@RequestParam("userTel") String userTel);
SpringCloud Feign报错:Method has too many Body parameters的更多相关文章
- SpringCloud Eureka 报错 无法启动问题
1.SpringCloud Eureka 报错 无法启动基本上都是spring boot的版本与spring cloud的版本不匹配导致的. <dependencyManagement> ...
- 【spring data jpa】repository中使用@Query注解使用hql查询,使用@Param引用参数,报错:For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on
在spring boot中, repository中使用@Query注解使用hql查询,使用@Param引用参数 如题报错: For queries with named parameters you ...
- Mybatis报错:Parameter 'list' not found. Available parameters are [groupList, param1]
GroupDao.java 里面定义的方法: void batchInsertLog(@Param("groupList") List<MktPromotionIntegra ...
- Mybatis传多个参数的问题 及MyBatis报错 Parameter '0' not found. Available parameters are [arg1, arg0, param1 问题
对于使用Mybatis ,传多个参数,我们可以使用对象封装外,还可以直接传递参数 对象的封装,例如查询对象条件basequery对象 <select id="getProductByP ...
- Feign报错Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client
问题描述 使用Feign调用微服务接口报错,如下: java.lang.RuntimeException: com.netflix.client.ClientException: Load balan ...
- spring cloud feign 报错 feign.FeignException$MethodNotAllowed: status 405 reading 解决
1.前言 出现报错 feign.FeignException$MethodNotAllowed: status 405 reading XXXXX 需要检查 接口的请求参数是否一致 请求参数是否正确添 ...
- Feign 报错:The bean 'service-producer.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.
报错: 2019-09-17 20:34:47.635 ERROR 59509 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ******* ...
- deepin下启动自己的springcloud服务报错
java.nio.file.AccessDeniedException: /home/msan/logs/csp/sentinel-record.log.2021-01-04.0.2.lck at s ...
- mybatis 批量insert,update报错 The error occurred while setting parameters
数据脚本执行正常,但是报错,搜索关键信息 The error occurred while setting parameters ,发现了解决帖子: http://blog.csdn.net/jing ...
随机推荐
- Whether to hide the cookie from JavaScript
w禁用js访问特定cookie. https://codeigniter.com/userguide3/helpers/cookie_helper.html $this->load->he ...
- ubuntu安装wine的方法
使用命令行安装: 1.打开终端,使用命令:sudo apt-get install wine 2.它可能会出现选择哪个版本的安装,develop是开发版本,stable是稳定版本. 通常我们选择sta ...
- EIT: where is it now and what lies ahead?
EIT: where is it now and what lies ahead? Electrical impedance tomography (EIT) is an emerging clini ...
- Zipline入门教程
Zipline Beginner Tutorial Basics 基础 Zipline is an open-source algorithmic trading simulator written ...
- python学习笔记(四)— 补充
函数return多个值 函数如果有多个return值,那么会生成一个元组里面 def hello(a,b,c,d): return a,b,c,d res =hello('aa','cc','dd', ...
- TCP和UDP的区别?
答:TCP提供面向连接的.可靠的数据流传输,而UDP提供的是非面向连接的.不可靠的数据流传输.TCP传输单位称为TCP报文段,UDP传输单位称为用户数据报.TCP注重数据安全性,UDP数据传输快,因为 ...
- ruamel.yaml 将字典写入yaml文件
#安装 pip install ruamel.yaml import os from ruamel import yaml # 将字典写入到yaml my_dic = { 'name': '张三', ...
- 009-Hadoop Hive sql语法详解4-DQL 操作:数据查询SQL-select、join、union、udtf
一.基本的Select 操作 语法SELECT [ALL | DISTINCT] select_expr, select_expr, ...FROM table_reference[WHERE whe ...
- 使用uiautomatorviewer获取元素
1.进入以下目录,Androidsdk-tools,双击uiautomatorviewer.bat,然后弹出UI Automator Viewer窗口,按截图操作, 获取当前页面,然后点击相应的元素, ...
- Python:6种标准数据类型
原文地址https://www.cnblogs.com/qin1991/p/5910145.html #!/usr/bin/python3 #python的基本语法和数据类型 #python3中 一行 ...