Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled. 2023-06-07 09:32:39.680 ERROR 12220 --- [ main] o.s.boot.SpringApplication : Application run failed org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'guanggaoController' method com.youzi.controller.GuanggaoController#toGuanggaoManagerHtml(Guanggao, Model) to {GET /toGuanggao}: There is already 'commonsController' bean method com.youzi.controller.CommonsController#toGuanggaoManagerHtml() mapped.
时间: 2024-04-25 22:27:58 浏览: 156
详解spring applicationContext.xml 配置文件
5星 · 资源好评率100%
这个错误是由于在Spring框架中存在多个映射到同一URL的方法,导致框架无法确定要调用哪个方法。具体地说,错误信息中提到了两个方法:`com.youzi.controller.GuanggaoController#toGuanggaoManagerHtml(Guanggao, Model)` 和 `com.youzi.controller.CommonsController#toGuanggaoManagerHtml()`。你需要检查这两个方法的映射路径是否存在重复,如果有,则需要修改其中一个方法的映射路径,以确保路径唯一。另外,你也可以使用`@RequestMapping`注解的`value`属性来明确指定方法的URL映射路径,以避免这种错误的出现。
阅读全文