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

 

This exception occurs because the citations using feign client when the parameters are not modified with annotations

1.1GET way
wrong wording

@RequestMapping(value="/test", method=RequestMethod.GET)

Model test(final String name, final int age);

Startup services, will be reported the following exception:

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)

Abnormal: When using Feign, if sending a get request, you need to add @RequestParam comment before the modification request parameters, Controller which can be used without modification of the comment.

Correct wording

@RequestMapping(value="/test", method=RequestMethod.GET)

Model test(@RequestParam("name") final String name,@RequestParam("age") final int age);

1.1POST way
wrong wording

public int save(@RequestBody final Person p, @RequestBody final UserModel user);

feign you can have multiple @RequestParam, but only no more than one @RequestBody.

Correct wording

public int save(@RequestBody final Person p,@RequestParam("userId") String userId,@RequestParam("userTel") String userTel);

Guess you like

Origin www.cnblogs.com/wbl001/p/11795859.html