Caused by: java.lang.IllegalStateException: Method has too many Body parameters
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);
转自:https://www.cnblogs.com/chenkeyu/p/8482276.html
Caused by: java.lang.IllegalStateException: Method has too many Body parameters的更多相关文章
- 【异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters
出现此异常原因是引文使用feign客户端的时候,参数没有用注解修饰 1.1GET方式错误写法 @RequestMapping(value="/test", method=Reque ...
- Feign调用远程服务报错:Caused by: java.lang.IllegalStateException: Method getMemberInfo not annotated with HTTP method type (ex. GET, POST)
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'ord ...
- Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)
使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...
- 【spring boot】【elasticsearch】spring boot整合elasticsearch,启动报错Caused by: java.lang.IllegalStateException: availableProcessors is already set to [8], rejecting [8
spring boot整合elasticsearch, 启动报错: Caused by: java.lang.IllegalStateException: availableProcessors ], ...
- Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available
java.lang.IllegalStateException: Failed to load ApplicationContext at org.springframework.test.co ...
- Caused by: java.lang.IllegalStateException: Ambiguous mapping found
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...
- Caused by: java.lang.IllegalStateException: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackOverflowError
SLF4J: Detected both log4j-over-slf4j.jar AND slf4j-log4j12.jar on the class path, preempting StackO ...
- Caused by: java.lang.IllegalStateException: Expected raw type form of org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$Match
spring 4.0.2,mybatis 3.2.6,aspectjweaver 1.8.10 使用的时候,报错: Caused by: java.lang.IllegalStateException ...
- Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.xService }: app is in background uid UidRecord(一)
Caused by java.lang.IllegalStateException Not allowed to start service Intent { cmp=com.x.x.x/.x.x.x ...
随机推荐
- /proc 目录详细说明
/proc路径详细: Linux 内核提供了一种通过 /proc 文件系统,在运行时访问内核内部数据结构.改变内核设置的机制.proc文件系统是一个伪文件系统,它只存在内存当中,而不占用外存空间.它以 ...
- Html中 <tr> 标签的隐藏与显示
TR标签的隐藏与显示:block(显示)和none(隐藏) <tr style="display:none"> <tr id="sample" ...
- php截取字符去掉最后一个字符
$str="中国.美国.俄罗斯.德国."$str=substr($str,0,-1); 输出结果为:中国.美国.俄罗斯.德国
- MySQL -- Innodb是如何处理自增列的
对于那些向带有自增列的表中插入行的语句,Innodb提供一种可配置的锁定机制,这种锁定机制可以显著提高SQL语句的可伸缩性和性能. Innodb中为了使用自增机制,自增列必须是索引的部份,从而可以使用 ...
- RHEL7 禁用gnome-inital-setup
每次登陆系统后,都会跳出页面gnome-inital-setup 如果觉得讨厌,可以禁止该页面的出现: mkdir ~/.config echo "yes" >> ~/ ...
- 纯css打造美丽的html表格
花了点时间,自己做了个美丽的html表格,採用技术有css,html,其它的废话我也不多说了,直接上图.上代码. 界面图片: HTML代码: <%@ page language="ja ...
- hdu 4223 Dynamic Programming? (dp)
//连续的和的绝对值最小 # include <stdio.h> # include <string.h> # include <algorithm> # incl ...
- 使用 vue-cli 实现组件之间数据交换
1 使用脚手架工具用 webpack 模板初始化项目,用 webstorm 打开项目.src 目录下是要编写的源文件. main.js 文件 是主入口文件, 在es6语法中,:function(){} ...
- 简简单单搞掂恼人的Laravel 5安装
想折腾下Laravel 5了.Laravel是这世界上最好且没有之一的语言──PHP──的众多框架中的一个,是我比较感兴趣的PHP Web Framework. 但是安装Laravel可不是件容易的事 ...
- MAME模拟器使用简单教程
平时比较喜欢玩小时候的街机游戏,一开始用Winkawas,后来改用MAME,原因无他,mame是开源软件,更新更稳定可靠,但是它也有几个问题,记录一下. 1.MAME官网:www.mamedev.or ...