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

SpringCloud Feign报错:Method has too many Body parameters的更多相关文章

  1. SpringCloud Eureka 报错 无法启动问题

    1.SpringCloud Eureka 报错 无法启动基本上都是spring boot的版本与spring cloud的版本不匹配导致的. <dependencyManagement> ...

  2. 【spring data jpa】repository中使用@Query注解使用hql查询,使用@Param引用参数,报错:For queries with named parameters you need to use provide names for method parameters. Use @Param for query method parameters, or when on

    在spring boot中, repository中使用@Query注解使用hql查询,使用@Param引用参数 如题报错: For queries with named parameters you ...

  3. Mybatis报错:Parameter 'list' not found. Available parameters are [groupList, param1]

    GroupDao.java 里面定义的方法: void batchInsertLog(@Param("groupList") List<MktPromotionIntegra ...

  4. Mybatis传多个参数的问题 及MyBatis报错 Parameter '0' not found. Available parameters are [arg1, arg0, param1 问题

    对于使用Mybatis ,传多个参数,我们可以使用对象封装外,还可以直接传递参数 对象的封装,例如查询对象条件basequery对象 <select id="getProductByP ...

  5. Feign报错Caused by: com.netflix.client.ClientException: Load balancer does not have available server for client

    问题描述 使用Feign调用微服务接口报错,如下: java.lang.RuntimeException: com.netflix.client.ClientException: Load balan ...

  6. spring cloud feign 报错 feign.FeignException$MethodNotAllowed: status 405 reading 解决

    1.前言 出现报错 feign.FeignException$MethodNotAllowed: status 405 reading XXXXX 需要检查 接口的请求参数是否一致 请求参数是否正确添 ...

  7. Feign 报错:The bean 'service-producer.FeignClientSpecification', defined in null, could not be registered. A bean with that name has already been defined in null and overriding is disabled.

    报错: 2019-09-17 20:34:47.635 ERROR 59509 --- [ main] o.s.b.d.LoggingFailureAnalysisReporter : ******* ...

  8. deepin下启动自己的springcloud服务报错

    java.nio.file.AccessDeniedException: /home/msan/logs/csp/sentinel-record.log.2021-01-04.0.2.lck at s ...

  9. mybatis 批量insert,update报错 The error occurred while setting parameters

    数据脚本执行正常,但是报错,搜索关键信息 The error occurred while setting parameters ,发现了解决帖子: http://blog.csdn.net/jing ...

随机推荐

  1. UVALive 6933 Virus synthesis(回文树)

    Viruses are usually bad for your health. How about ghting them with... other viruses? In this proble ...

  2. HTML代码大全

    1.html的简介* 什么是html?- HyperText Markup Language:超文本标记语言,网页语言** 超文本:超出文本的范畴,使用html可以轻松实现这样操作** 标记:html ...

  3. Markdown安装与简单使用

    早就听过Markdown的大名了,说是最适合程序员的编辑器,一点也不为过.平时写文章,写博客.除了内容以外,还要被一堆繁琐的样式困扰,毕竟样式太难看,既是自己的文章,也会懒得看的.今天正好看到博客上面 ...

  4. 联合约束 CONCAT()

    w SELECT 原理. SELECT * FROM wz WHERE CONCAT(wint,wchar) NOT IN (SELECT CONCAT(wint,wchar) FROM wa); S ...

  5. 用flask开发个人博客(4)—— flask中4种全局变量

    https://blog.csdn.net/hyman_c/article/details/53512109 一  current_app current_app代表当前的flask程序实例,使用时需 ...

  6. Ubuntu 下 chromium浏览器的标签乱码

    最近使用ubuntu系统,安装了个chromium浏览器,标题不会乱码,不过标签乱码,火狐浏览器没有这个问题,强大的互联网告诉我是少字体的原因,执行下面的指令即可. sudo apt-get inst ...

  7. 【c++】生成浮点随机数

    c++11:std::uniform_real_distribution<>直接求(尖括号不填默认生成double) 随机10个在1-2之间的浮点数 #include <random ...

  8. 13.Query for Null or Missing Fields-官方文档摘录

    1 插入数据 db.inventory.insertMany([ { _id: 1, item: null }, { _id: 2 } ]) 2 查询null值 db.inventory.find({ ...

  9. Ubuntu安装Python3 和卸载

    Python2中文的解决 在py文件第一行添加 #coding=utf-8 1 规范的应该这么写 #-*- coding:utf-8 -*- 1 安装python 系统默认安装Python2 安装Py ...

  10. sipp模拟freepbx分机测试(SIP协议调试)

    1.sipp的安装 1) 在centos 7.2下安装 yum install make gcc gcc-c++ ncurses ncurses.x86_64 ncurses-devel ncurse ...