我试图用Spring Boot创建RestApi服务
我有家长课
public abstract class GenericRestController{ @RequestMapping( produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.GET, path = "/list" ) @ApiOperation("Get all entities") public SimpleResponse create(@RequestParam(required = false) Integer page, @RequestParam(required = false) Integer size) { ..somehting } }
和
@RestController @Api("Parameters") @RequestMapping(value = Controller.PARAMETERS) public class ParameterController extends GenericRestController { @RequestMapping( produces = MediaType.APPLICATION_JSON_VALUE, method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, ) @ApiOperation("Create new entity") public SimpleResponse create(@RequestBody Parameter parameter, @PathVariable(value = "rate-id") Long rateId) { ...something } }
我收到错误
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'parameterController' method
public kz.sanscrit.cbs.common.pojo.SimpleResponse kz.sanscrit.cbs.rates.controllers.GenericRestController.create(E)
to {[/rates/{rate-id}/parameters],methods=[POST],consumes=[application/json],produces=[application/json]}: There is already 'parameterController' bean method
如何正确重载此方法,因为我需要从此GenericClass扩展其他方法,但是在创建的情况下,我还有其他附加参数
答案 0 :(得分:0)