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