There is already 'xxxxx' bean method

小鱼儿 2022-06-17 12:36 321阅读 0赞

今天写代码的时候遇到了如下问题

  1. 2017-04-26 11:17:02.198 WARN 6411 --- [ main] ationConfigEmbeddedWebApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: 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 'demoController' method public void cn.peakline.controller.DemoController.checkCode(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,java.lang.String) throws java.io.IOException to {[/demo/checkCode]}: There is already 'demoController' bean method public void cn.peakline.controller.DemoController.getCode(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse) mapped.

经过检查,是因为controller里有了多个相同的请求{[/demo/checkCode]},修改或者删除其他方法,确定只有一个请求名称即可

发表评论

表情:
评论列表 (有 0 条评论,321人围观)

还没有评论,来说两句吧...

相关阅读