【异常】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);
【异常】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=RequestMethod.GET) Model test ...
- 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 ...
- java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);
明明指定了请求方法类型还报错: 代码: @RequestMapping(value="/enterprise/detail",method = RequestMethod.POST ...
- Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)
使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...
- Caused by: java.lang.IllegalStateException: Ambiguous mapping found
Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...
- 【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: 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 ...
随机推荐
- Linux之lrzsz命令的安装
Linux之lrzsz命令的安装 1. lrzsz简介 什么是lrzsz? lrzsz是一款在linux里可代替ftp上传和下载的程序.在linux里可代替ftp上传和下载 rz:上传文件到服务器 s ...
- python常用函数 S
slice(int,int) 切片,可以为切片命名增加可读性. 例子: sorted(iterable, key) 排序,支持传入参数,例如通过itemgetter传入参数(itemgetter可以传 ...
- 【LeetCode】智商题 brainteaser(共3题)
[292]Nim Game [319]Bulb Switcher [777]Swap Adjacent in LR String (2019年2月13日,谷歌tag) 给了两个字符串start 和en ...
- opencl(九)----标量、向量数据类型
1.opencl 标量数据类型 bool char unsigned char/uchar short 16位有符号整数(补码) ushort int 32位有符号整数(补码) uint 32位无符号 ...
- ConcurrentSkipListMap--跳表的简单使用
import java.util.Map; import java.util.concurrent.ConcurrentSkipListMap; /** * 跳表的使用 */ public class ...
- 人生苦短_我用Python_configparser/yaml对配置文件读取/写入操作_010
第一,我们先开始安装yaml库,configparser是自带库,yaml库是针对读取yml文件,configparser现阶段我只用于读取conf文件 首先:1)对象文件为:data.yml,下面的 ...
- Pycharm的debug单步调试
首先设置断点,点击行号显示的一侧,在指定行设置断点.比如这里,我们设断点在创建对象时: .如果这时我们直接右键run这个代码.他还是会直接运行,不会理会断点 结果 所以要右键选择run下面的debug ...
- Java调用明华RF读写器DLL文件的方法
首先jdk必须得是32位的,IDE也必须是32位的(我用的idea,所以为了使用32位的,下载了2018年1月版本的). 明华RF读写器演示文件提供了一份名为mwrf32.dll的动态链接库文件 ja ...
- CDH6.3.1安装hue 报错
x 一.查看日志server运行日志 /var/log/cloudera-scm-server/cloudera-scm-server.log 2019-12-11 17:28:34,201 INFO ...
- CSS中的flex布局
1.flex 布局的概念 Flex是Flexible Box的缩写,意为"弹性布局",用来为盒状模型提供最大的灵活性.任何一个容器都可以指定为 Flex 布局,行内元素也可以通过 ...