【@RequestMapping】 Cannot map 'groupController' method

来源:互联网 发布:windows查看进程命令 编辑:程序博客网 时间:2024/05/29 16:36

报错信息


:java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'groupController' methodThere is already 'groupController' bean methodpublic 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地址;
RequestMapping

这里的saveGroup没有配置Value;
RequestMapping

因为Value默认的值是空值;
这里写图片描述

所以有两个@RequestMapping的Value都没有,这样系统都默认为空,这会导致冲突路径相同(都为空),所以才会报错;我注销了其中一个没有写Value的方法,果然,报错消失了;
报错信息

所以,解决的办法是:
1.给没有Value的方法映射配置值,value即路径别名;
2.注销掉默认值都为空,或者value相同的映射;

阅读全文
1 0