【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method

简介: 【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method

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")改为不同的请求路径,查看报错地方,找出同一请求映射到两个方法的请求路径,修改后即可!

 

完结!


相关文章
|
Java Docker 微服务
【Java异常】Caused by: java.lang.IllegalArgumentException: method GET must not have a request body
【Java异常】Caused by: java.lang.IllegalArgumentException: method GET must not have a request body
203 1
|
Java Maven
【异常】java: Internal error in the mapping processor: java.lang.NullPointerException
【异常】java: Internal error in the mapping processor: java.lang.NullPointerException
338 0
|
7月前
|
Java Spring
java.lang.Exception: Method a() should be public
java.lang.Exception: Method a() should be public
77 0
|
7月前
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘quanZiController‘ method
52 0
|
Java
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
【Java异常】java.lang.IllegalStateException: Ambiguous mapping. Cannot map ‘xxx‘ method
167 0
|
前端开发 Cloud Native Java
已解决‘Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPoint
已解决‘Failed to start bean ‘documentationPluginsBootstrapper‘; nested exception is java.lang.NullPoint
163 0
|
Java Spring
【Java异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters
【Java异常】Caused by: java.lang.IllegalStateException: Method has too many Body parameters
166 0
|
Java 测试技术
java.lang.IllegalStateException Unable to find a @SpringBootConfiguration代码报错
java.lang.IllegalStateException Unable to find a @SpringBootConfiguration代码报错
Failed to start bean ‘documentationPluginsBootstrapper nested exception is java.lang.NullPointerE
Failed to start bean ‘documentationPluginsBootstrapper nested exception is java.lang.NullPointerE
66 0
|
自然语言处理
解决java.lang.IllegalStateException: Duplicate key异常
记录解决java.lang.IllegalStateException: Duplicate key异常
777 0