出现此异常原因是引文使用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的更多相关文章

  1. Caused by: java.lang.IllegalStateException: Method has too many Body parameters

    feign多参数问题1.1GET方式错误写法 @RequestMapping(value="/test", method=RequestMethod.GET) Model test ...

  2. 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 ...

  3. java.lang.IllegalStateException: Method get not annotated with HTTP method type (ex. GET, POST);

    明明指定了请求方法类型还报错: 代码: @RequestMapping(value="/enterprise/detail",method = RequestMethod.POST ...

  4. Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)

    使用Mediaplayer播放本地音频,在第二次调用mediaplayer.setDataSource()时报错如下: Caused by: java.lang.IllegalStateExcepti ...

  5. Caused by: java.lang.IllegalStateException: Ambiguous mapping found

    Caused by: java.lang.IllegalStateException: Ambiguous mapping found. Cannot map ‘myCockpitMgrControl ...

  6. 【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 ], ...

  7. Caused by: java.lang.IllegalStateException: javax.websocket.server.ServerContainer not available

    java.lang.IllegalStateException: Failed to load ApplicationContext    at org.springframework.test.co ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 无法用另一台电脑上的navicat链接主机数据库lost connection toMYSQl server at "handshake":reading inital communication packet,system error:34

    同事要用navicat登陆我的数据库,主机地址和密码都没错,但是报错,lost connection toMYSQl server at "handshake":reading i ...

  2. html5 实例渐变

    代码实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  3. 第05章 AOP细节

    第05章 AOP细节 1.切入点表达式 1.1 作用 通过表达式的方式定位一个或多个具体的连接点. 1.2 语法细节 ①切入点表达式的语法格式 execution([权限修饰符] [返回值类型] [简 ...

  4. vs2005下opengl(glut)的配置记录

    摘自:http://blog.csdn.net/joeblackzqq/article/details/6956959 首先参考了网上的安装配置环境部分:http://blog.csdn.net/Id ...

  5. js image转canvas不显示

    今天在项目开发中遇到了image转canvas不显示的问题,最后翻了不少资料才发现问题出现在图片加载上 如果你的代码是这样的,那么不显示的原因就是img没有加载完成 function convertI ...

  6. 【leetcode】668. Kth Smallest Number in Multiplication Table

    题目如下: 解题思路:几乎和[leetcode]719. Find K-th Smallest Pair Distance 的方法一样.只不过一个是减法一个是乘法,还有一点区别是[leetcode]7 ...

  7. Voting与OCR

    VotingVoting Disk里面记录着节点成员的信息.如RAC数据库中有哪些节点成员,节点增加或者删除时也同样会将信息记录进来.Voting Disk必须存放在共享存储上.crsctl quer ...

  8. JMeter之Beanshell用法

    1. 获取JMeter脚本中的变量 ${demoParam} String demo = vars.get("demoParam"); 2. 将数据保存到JMeter脚本中的变量 ...

  9. Python基础教程(016)--Python2和Python3的介绍

    前言 Python2和Python3的区别 内容 Python3是现在和未来的主要版本 Python3没有考虑向下兼容. 官方提供了一个Python过度版本Python2.6 Python2.6及支持 ...

  10. delphi 创建桌面快捷方式

    unit UShorCut; interface uses Windows, Classes, SysUtils,Dialogs, ShlObj, ComObj, ActiveX, Registry; ...