There is already 'xxxxx' bean method

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

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]},修改或者删除其他方法,确定只有一个请求名称即可

你可能感兴趣的:(java)