feign多参数问题
1.1GET方式
错误写法html
@RequestMapping(value="/test", method=RequestMethod.GET) java
Model test(final String name, final int age); spring
启动服务的时候,会报以下异常:springboot
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) restful
异常缘由:当使用Feign时,若是发送的是get请求,那么须要在请求参数前加上@RequestParam注解修饰,Controller里面能够不加该注解修饰。app
正确写法rest
@RequestMapping(value="/test", method=RequestMethod.GET) htm
Model test(@RequestParam("name") final String name,@RequestParam("age") final int age); blog
1.1POST方式
错误写法get
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);