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")
粗心了
推荐阅读
-
软件开发程序猿日常必备,现用现查&日志记录
-
小程序云开发获取不到数据库记录的解决方法
-
Android开发导入项目报错Ignoring InnerClasses attribute for an anonymous inner class的解决办法
-
PHP Curl https跳过ssl证书认证报错记录及解决
-
(0075)iOS开发之cocoapods使用OpenSSL出现报错问题及解决方法
-
记录一次JavaWeb开发的乱码解决
-
记录Yii2框架开发微信公众号遇到的问题及解决方法
-
iOS开发之Xcode 7 App Transport Security has blocked a cleartext HTTP 报错问题的解决方案
-
Ueditor的controller.jsp文件总是报错说包没有import问题解决
-
关于Android官方开发教程中EditText editText = (EditText) findViewById(R.id.editText);报错的解决办法