沈超琦的博客

STAY HUNGRY,STAY FOOLISH

文章

FeignClient中每一个@RequestParam 都要设置value,否者报错

消费方代码 @FeignClient(name = “another-project-name”) public interface demoClient { @GetMapping(value = "/test") Boolean test(@RequestParam("userID")String userID); } 提供方代码 @RestController public class DemoController { @GetMapping(value = "/test") Boolean test(@RequestParam("userID")String userID){ ...... } }

使用feignClient调用接口 报错Method has too many Body parameters]

1、报错 Method has to many Body parmeters ,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里面....

STAY HUNGRY,STAY FOOLISH

© 2020 沈超琦的博客

Powered by Bolo
Theme self-bolo-sakura by Mashiro
浏览 2310 文章 20 评论 3
浙ICP备18010929号

主题 | Theme