Feign fallcallback 报 There is already ‘XXXXX‘ bean method的错误。

启动控制台后报:

There is already 'feignItemServiceFallback' bean method

导致这个错误是由于将 @RequestMapping注解了在接口上。

@RequestMapping("/itemService")
public interface ItemService {

     @RequestMapping("/item")
     Item findItemById(@RequestParam(name = "id") Long id);

    @RequestMapping("/{id}")
    Item findItemByPathId(@PathVariable(name = "id") Long id);

    @RequestMapping(value = "/save",method = RequestMethod.POST)
    Item save(@RequestBody Item item);

}

将它移到方法上即可。

public interface ItemService {

     @RequestMapping("/itemService/item")
     Item findItemById(@RequestParam(name = "id") Long id);

    @RequestMapping("/itemService/{id}")
    Item findItemByPathId(@PathVariable(name = "id") Long id);

    @RequestMapping(value = "/itemService/save",method = RequestMethod.POST)
    Item save(@RequestBody Item item);

}

你可能感兴趣的:(Spring,Cloud,java,restful,spring)