报错信息
:java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'groupController' method
There is already 'groupController' bean method
public com.platform.common.model.Result<java.lang.String> com.fxrj.sis.group.web.GroupController.saveGroup(com.fxrj.sis.group.model.Group,org.springframework.validation.BindingResult) mapped.
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'groupController' method
public com.platform.common.model.Result<java.lang.String> com.fxrj.sis.group.web.GroupController.deleteGroup(com.fxrj.sis.group.model.Group)
报错原因是:
我有两个@RequestMapping的Value没有配置;
*
因为Value是地址Path的别名,所以缺少了Value,Spring 的bean配不起来;
*
这里delete的@RequestMapping没有配置value地址;
这里的saveGroup没有配置Value;
因为Value默认的值是空值;
所以有两个@RequestMapping的Value都没有,这样系统都默认为空,这会导致冲突路径相同(都为空),所以才会报错;我注销了其中一个没有写Value的方法,果然,报错消失了;
所以,解决的办法是:
1.给没有Value的方法映射配置值,value即路径别名;
2.注销掉默认值都为空,或者value相同的映射;