第一章 Unsatisfied dependency expressed through field 'feignXxService'
初始代码:
ModelMap<Something> getSomething(String testA, String testB);
报错信息:
Error creating bean with name 'xxServiceImpl': Unsatisfied dependency expressed through field 'feignXxService'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.test.test.xx.FeignXxService': FactoryBean threw exception on object creation; nested exception is java.lang.IllegalStateException: Method getSomething not annotated with HTTP method type (ex. GET, POST)
案情分析:
这是两个服务间的调用,服务A调用了服务B的getSomething方法,但是服务B并没有设置可远程调用。
改代码后:
@PostMapping(value = "/test/getSomething")
ModelMap<Something> getSomething(String testA, String testB);
第二章 Method has too many Body parameters
报错信息:
Method has too many Body parameters: public abstract org.springframework.ui.ModelMap com.test.test.xx.FeignXxService.getSomething(java.lang.String,java.lang.String)
案情分析:
服务B中没有指明访问的方式,而它默认是RequestBody,导致无法识别参数,报了错。
最终代码:
@PostMapping(value = "/test/getSomething")
ModelMap<Something> getSomething(@RequestParam(value = "testA") String testA,
@RequestParam(value = "testB") String testB);