目录
1、异常信息
在运行Springboot项目时,出现了如下异常信息:模糊映射。无法映射的xxx方法,异常信息如下:
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'tacticsInfoController' method
public com.soft.framework.core.response.PageResult<?> com.soft.back.operation.controller.openplatform.TacticsInfoController.getOutdevModelList(java.lang.Integer)
to {GET /tactics/getOutdevFactoryList}: There is already 'tacticsInfoController' bean method
public com.soft.framework.core.response.PageResult<?> com.soft.back.operation.controller.openplatform.TacticsInfoController.getOutdevFactoryList(java.lang.String) mapped.
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.assertUniqueMethodMapping(AbstractHandlerMethodMapping.java:618)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping$MappingRegistry.register(AbstractHandlerMethodMapping.java:586)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.registerHandlerMethod(AbstractHandlerMethodMapping.java:312)
at org.springframework.web.servlet.handler.AbstractHandlerMethodMapping.lambda$detectHandlerMethods$1(AbstractHandlerMethodMapping.java:282)
at java.util.LinkedHashMap.forEach(LinkedHashMap.java:676)
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:1821)
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1758)
... 50 common frames omitted
2、异常原因
控制层同一请求映射到两个方法,即controller层的方法指定了两个相同的路径,也就是说同一个项目中有两个@RequestMapping("/xxx")完全相同,就会报此错误信息
3、解决办法
两个相同的@RequestMapping("/xxxx/xxxx")改为不同的请求路径,查看报错地方,找出同一请求映射到两个方法的请求路径,修改后即可!
完结!