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的更多相关文章

  1. 【异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters

    出现此异常原因是引文使用feign客户端的时候,参数没有用注解修饰 1.1GET方式错误写法 @RequestMapping(value="/test", method=Reque ...

  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. Caused by:java.lang.IllegalStateException at android.media.MediaPlayer._setDataSource(Native Method)

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

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

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

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

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

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

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

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

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

随机推荐

  1. mongodb c++ driver 2.0编译使用

    安装boost1.48.0 在boost的官网下载boost1.48.0,链接例如以下: http://sourceforge.net/projects/boost/files/boost/1.48. ...

  2. java数组随机排序实现代码

    例一 代码如下 复制代码 import java.lang.Math;import java.util.Scanner;class AarrayReverse{ public static void ...

  3. 解决Myeclipse中导入自定义的配色方案后,JSP中的js代码块为白色背景的问题

    捣鼓了大半个上午,终于搞定.这样设置就可以了: 点击MyEclipse上方的菜单栏中的window菜单.选择Preferences菜单项.在弹出的窗口的左侧树形菜单依次选择:MyEclipse.Fil ...

  4. Ajax接收并显示后台传来的list集合内的数据信息

    最近在学习Ajax做一个留言系统的时候碰到需要将list集合从后台传到前台ajax接收并显示的情况,在网上搜了很多,但很多情况都不是和我遇见的情况一样的,现在,直接贴出我的问题及解决方法. 后台代码: ...

  5. jsonp原理和jquey jsonp原理实践

    $.ajax({ type: "get", async: false, url: "ajax.htm", dataType: "jsonp" ...

  6. idea自动编译

    idea修改后台代码自动编译 On 'update' action = Update classes and resources On frame deactivation = Update clas ...

  7. Oozie4.2 安装部署、以及example测试

    编译: 使用的环境是:Hadoop2.6.0.Spark1.4.0.Hive0.13.1.Sqoop1.4.4 编译Oozie的命令:./mkdistro.sh -Phadoop-2 -Dhadoop ...

  8. 自定义Django中间件(登录验证中间件实例)

    前戏 我们在前面的课程中已经学会了给视图函数加装饰器来判断是用户是否登录,把没有登录的用户请求跳转到登录页面.我们通过给几个特定视图函数加装饰器实现了这个需求.但是以后添加的视图函数可能也需要加上装饰 ...

  9. numRecordsIn 在哪里实现?

    /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreem ...

  10. 【ARM】2440裸机系列-RTC数字时钟

    功能 裸机程序,实现LCD显示数字时钟 主要代码   1)背景绘制 void Brush_ U32 c) { int x,y ; for ( y = 0 ; y < LCD_HEIGHT ; y ...