出现此异常原因是引文使用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. Codeforces Round #392 (Div. 2) - A

    题目链接:http://codeforces.com/contest/758/problem/A 题意:给定N个城市的福利,国王现在想让每个城市的福利都一致.问最少需要花多少钱使得N个城市的福利值都一 ...

  2. mongdb 副本集的原理、搭建、应用

    在了解了这篇文章之后,可以进行该篇文章的说明和测试.MongoDB 副本集(Replica Set)是有自动故障恢复功能的主从集群,有一个Primary节点和一个或多个Secondary节点组成.类似 ...

  3. Go的学习 append的使用

    1. package main; import "fmt" func test () { ],,,,}; s:=a[:] fmt.Printf(]) s=append(s,); s ...

  4. [BZOJ2341][Shoi2011]双倍回文 manacher+std::set

    题目链接 发现双倍回文串一定是中心是#的回文串. 所以考虑枚举#点.发现以\(i\)为中心的双倍回文的左半部分是个回文串,其中心一定位于\(i-\frac{pal[i]-1}2\)到\(i-1\)之间 ...

  5. wxpython总体

    人到夏天就特别懒 from math import * import wx def sin_fun(event): a=text_angle.GetValue() b=sin(radians(floa ...

  6. 【JVM】垃圾收集器和收集器的选择策略

    前言:新生代的收集器有:Serial,ParNew,Parallel Scavenge等.老年代有:CMS,SerialOld,Paraller Old等.接下来将深入理解各个垃圾收集器的原理,以及它 ...

  7. Redis缓存在django中的配置

    django  settings中的配置 # 缓存 CACHES = { "default": { "BACKEND": "django_redis. ...

  8. 2019 GNTC 阿里云参会分享:云原生SDWAN网络2.0 一站式上云服务

    本次10/22-24 南京2019 GNTC大会上,阿里云网络云原生SDWAN网络2.0 由于独特的云原生定位.创新的解决方案,及成熟的应用案例.行业用户,获得行业媒体C114中国通信网.产业专家高度 ...

  9. npm和gem

    https://blog.csdn.net/u011099640/article/details/53083845

  10. Java Web学习总结(1)Tomcat使用教程

    一,简介 Tomcat是一个实现了JAVA EE标准的最小的WEB服务器,是Apache 软件基金会的Jakarta 项目中的一个核心项目,由Apache.Sun 和其他一些公司及个人共同开发而成.因 ...