新手经常遇到的错误

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);

feign客户端传参数报错的更多相关文章

  1. Bug集锦-Spring Cloud Feign调用其它接口报错

    问题描述 Spring Cloud Feign调用其它服务报错,错误提示如下:Failed to instantiate [java.util.List]: Specified class is an ...

  2. 单元测试时候使用[ClassInitialize]会该方法必须是静态的公共方法,不返回值并且应采用一个TestContext类型的参数报错的解决办法

    using Microsoft.VisualStudio.TestTools.UnitTesting; 如果该DLL应用的是 C:\Program Files\Microsoft Visual Stu ...

  3. Linux - xshell上传文件报错乱码

    xshell上传文件报错乱码,解决方法 rz -be 回车 下载sz  filename

  4. Azkban上传文件报错installation Failed.Error chunking

    azkaban 上传文件报错Caused by: java.sql.SQLException: The size of BLOB/TEXT data inserted in one transacti ...

  5. Tomcat上传文件报错:returned a response status of 403 Forbidden

    出现这样的错误是没有权限对服务器进行写操作.需要在这个项目所在的tomcat中配置可写操作即可: 在tomcat的web.xml添加下面代码: <init-param><param- ...

  6. 【spring mvc】后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface

    后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate ...

  7. rz上传文件报错:rpm Read Signature failed: sigh blob(1268): BAD, read returned 0

    上传文件报错: [root@www localdisk]# rpm -ivh cobbler* error: cobbler-2.8.4-4.el7.x86_64.rpm: rpm  Read  Si ...

  8. js 传参报错 参数含有数字、字母组合的字符串SyntaxError: identifier starts immediately after numeric literal

    报错的意思是标识符以数字开头,这是因为js是弱类型的语言当发现第一个数字是就自动转化为数字类型的但是其中还含有字符所以报了错,‘ 报错的原因是因为我们想传的字符串,但是js却当成数字,所以需要给传的参 ...

  9. springmvc的MultipartFile参数如果不上传文件报错的问题

    @RequestMapping(value = "/updateInformation",method = RequestMethod.POST) @ResponseBody pu ...

随机推荐

  1. PHP读取xml方法介绍

    一,什么是xml,xml有什么用途 XML(Extensible Markup Language)即可扩展标记语言,它与HTML一样,都是SGML(Standard Generalized Marku ...

  2. NO2:设置RedHat Linux下的samba开机启动

    安装的samba默认不是开机启动的,这样每次都要进入系统人为启动,很不方便,当然系统肯定可以设置开机启动的. 因为我的是RedHat Linux系统,支持chkconfig命令直接配置,会简单些,其它 ...

  3. 使用msiexec提取msi包里的文件

    核心:如需把d盘下abc.msi文件解包到目录d:\abc,操作如下:打开命令提示符,输入msiexec /a "d:\abc.msi" /qb TARGETDIR="D ...

  4. MySQL 5.7新特性

    新增特性 Security improvements. MySQL.user表新增plugin列,且若某账户该字段值为空则账户不能使用.从低版本MySQL升级至MySQL5.7时要注意该问题,且建议D ...

  5. poj1631——树状数组求LIS

    题目:http://poj.org/problem?id=1631 求LIS即可,我使用了树状数组. 代码如下: #include<iostream> #include<cstdio ...

  6. ng2父子模块通信@ViewChild和@Inject

    一.@ViewChild 父组件中使用@ViewChild拿到子组件的变量和方法(父组件可调用子组件的方法和变量) parent.component.ts: import { Component, O ...

  7. js 元素的各种宽度高度

    一.属性 1.只读属性 所谓的只读属性指的是DOM节点的固有属性,该属性只能通过js去获取而不能通过js去设置,而且获取的值是只有数字并不带单位的(px,em等),如下: 1)clientWidth和 ...

  8. ABP启动流程分析

    添加服务与注册中间件 public IServiceProvider ConfigureServices(IServiceCollection services) { // Configure Abp ...

  9. B - Simple Game

    B - Simple Game Time Limit:1000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Su ...

  10. 使用gdb调试c程序莫名退出定位 exit 函数

    gdb 程序名称 b exit //设置exit函数断点 run //运行程序 bt //查看程序调用堆栈,定位到exit所在行