1. java.lang.illegalStateException : Method getChildren not annotated with HTTP method type (ex.post,get)
以下两种注解是等价的
@RequestMapping(value = “/system/regions/parent/{parent_id}”, method = RequestMethod.GET)
@GetMapping(“/regions/parent/{parent_id}”)
但是在Feign的使用中,@GetMapping(“”)是不能直接使用的,所以会出现没有指定HTTP类型的异常
2. java.lang.IllegalStateException: PathVariable annotation was empty on param 0
参数标注不能为空,问题类型同上,
public List<Regions> getChildren(@PathVariable int parent_id) {
return regionsManager.listChildren(parent_id);
}
此方法中使用了@PathVariable int parent_id,而在Feign中应该使用@PathVariable(“parent_id”) int parent_id,或@PathVariable(value=”parent_id”) int parent_id
3. Request method ‘POST’ not supported
在参数的传递中,GET方法使用@RequestParam注解,POST方法使用@RequestBody注解,若传递参数时不加注解,则默认为@RequestBody注解,即POST方法,GET方法中有参数不加@RequestParam,被调用的服务就会提示POST是不被支持的