feign中,如果发送的是get请求去调用其它模块的方法,在接口处,形参需要添加 @RequestParam 注解。
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'dispathcherController': Unsatisfied dependency expressed through field 'userServiceFeign'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.offcn.webui.service.UserServiceFeign': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Method has too many Body parameters: public abstract com.offcn.common.response.AppResponse com.offcn.webui.service.UserServiceFeign.login(java.lang.String,java.lang.String)
会先报创建bean异常
org.springframework.beans.factory.UnsatisfiedDependencyException
再报
java.lang.IllegalStateException
其内容为:Method has too many Body parameters
将方法上添加注解 @RequestParam 后正常
//调用user模块的方法 @GetMapping("/user/login") public AppResponse<UserRespVo> login(@RequestParam String username,@RequestParam String password);
原因为spring底层校验导致的。