Spring MVC 3:为不存在的方法找到了不明确的映射

Val*_*llo 1 java spring spring-mvc

我有这个“创建”方法来映射/列出 POST 请愿书。我创建了一个重载方法“createEmpty()”以尝试一些东西,但后来被删除,因为它抛出了一个 org.springframework.beans.factory.BeanCreationException 用于不明确的映射。

问题是,在我删除所述方法后,我仍然收到异常。

@Controller
public class ListsController {

@RequestMapping(value = "/lists", method = RequestMethod.POST)
public @ResponseBody List create(@RequestBody List list) {
    return list;
}
Run Code Online (Sandbox Code Playgroud)

信息:开发应用服务器现在正在运行 2014 年 5 月 4 日下午 4:21:34 com.google.apphosting.utils.jetty.JettyLogger 警告警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0' 的 bean 时出错:bean 初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain。列表)映射。2014 年 5 月 4 日下午 4:21:34 com.google.apphosting.utils.jetty.JettyLogger 警告警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为 'org. springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。2014 年 5 月 4 日下午 4:21:34 com.google.apphosting.utils.jetty.JettyLogger 警告警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为 'org. springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。2014 年 5 月 4 日下午 4:21:34 com.google.apphosting.utils.jetty.JettyLogger 警告警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为 'org. springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。下午 34 点 com.google.apphosting.utils.jetty.JettyLogger 警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc”的 bean 时出错。 method.annotation.RequestMappingHandlerMapping#0':bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。下午 34 点 com.google.apphosting.utils.jetty.JettyLogger 警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc”的 bean 时出错。 method.annotation.RequestMappingHandlerMapping#0':bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。JettyLogger 警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0”的 bean 时出错:bean 初始化失败的; 嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。JettyLogger 警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0”的 bean 时出错:bean 初始化失败的; 嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0”的bean时出错:bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。factory.BeanCreationException:创建名为“org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0”的bean时出错:bean初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。bean 初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。bean 初始化失败;嵌套异常是 java.lang.IllegalStateException: Ambiguous mapping found。无法将 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() 映射到 {[/lists],methods=[POST],params=[],headers= [],consumes=[],produces=[],custom=[]}: 已经有 'listsController' bean 方法 public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs .tp.list_sharer.domain.List) 映射。

似乎 createEmpty() 缓存在某处......

小智 5

请尝试执行以下操作:
1. 如果您使用的是 eclipse - Project -> Clean。
2. 如果您使用的是 maven,请在部署前尝试清理和/或安装项目。



我看到您正在使用 Jetty,也许这些链接将有助于解决您的问题:
清理 Jetty - 删除“不必要”的东西
Jetty 运行旧战争 altought mvn clean is run