欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

controller日常开发报错解决记录

程序员文章站 2022-06-12 19:58:42
...

报错信息:

Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'templateRestApi' method 
public com.hierway.utility.api.result.ApiResult<java.util.List<com.hierway.vslm.domain.stream.TemplateNeedMatVo>> com.hierway.vslm.controller.TemplateRestApi.getOutPutNeedMaterialByTemps(java.lang.String,java.util.List<java.lang.String>,java.lang.Integer)
to {POST /vslm/template/query/output/material}: There is already 'templateRestApi' bean method
public com.hierway.utility.api.result.ApiResult<java.util.List<com.hierway.vslm.domain.stream.TemplateCraftNeedMatVo>> com.hierway.vslm.controller.TemplateRestApi.getOutPutCraftNeedMatsByTemp(java.lang.String,java.lang.String,java.lang.Integer) mapped.
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.assertUniqueMethodMapping(AbstractHandlerMethodMapping.java:621)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:589)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:315)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$1(AbstractHandlerMethodMapping.java:282)
	at java.util.LinkedHashMap.forEach(LinkedHashMap.java:684)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.detectHandlerMethods(AbstractHandlerMethodMapping.java:280)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.processCandidateBean(AbstractHandlerMethodMapping.java:252)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.initHandlerMethods(AbstractHandlerMethodMapping.java:211)
	at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.afterPropertiesSet(AbstractHandlerMethodMapping.java:199)
	at org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping.afterPropertiesSet(RequestMappingHandlerMapping.java:164)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1804)
	at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1741)
	... 50 common frames omitted

 

原来的controller层代码:

@RestController
@RequestMapping("/xxx")
public class TemplateRestApi {
    @Autowired
    private TemplateRestService templateRestService;
    private static Logger logger = LoggerFactory.getLogger(TemplateRestApi.class);

    @ApiOperation("根据规格号对应多模板,查询成品单位产出所需物料")
    @PostMapping("/template/query/output/material")
    public ApiResult<List<TemplateNeedMatVo>> getOutPutNeedMaterialByTemps(@RequestParam(value = "specId") String specId,
                                                                               @RequestParam(value = "tempIds") List<String> tempIds,
                                                                @RequestParam(name = "queryNum",required = false,defaultValue = "1") Integer queryNum) {
        List<TemplateNeedMatVo> templateNeedMatVoList = templateRestService.getOutPutNeedMaterialInfoByTemps(specId,tempIds,queryNum);
        return ResultUtil.success(templateNeedMatVoList);
    }

    @ApiOperation("根据模板查询各工艺单位产出所需物料")
    @PostMapping("/template/query/output/material")
    public ApiResult<List<TemplateCraftNeedMatVo>> getOutPutCraftNeedMatsByTemp(@RequestParam(value = "specId") String specId,
                                                                                @RequestParam(value = "tempId") String temp,
                                                                        @RequestParam(name = "queryNum",required = false,defaultValue = "1") Integer queryNum) {
        List<TemplateCraftNeedMatVo> templateCraftNeedMatVos = templateRestService.getOutPutCraftNeedMatsByTemp(specId,temp,queryNum);
        return ResultUtil.success(templateCraftNeedMatVos);
    }

}

 

问题跟踪:

报错提示:

Ambiguous mapping. Cannot map 'templateRestApi' method

模糊映射。无法映射'xxxx'方法

 

分析:

就是映射的路径冲突了....................

两个都是:

@PostMapping("/template/query/output/material")

粗心了

 

 

相关标签: 项目开发