简体   繁体   English

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

[英]Spring MVC 3 : Ambiguous mapping found for a non existing method

I have this "create" method which maps /lists POST petitions. 我有映射/列出POST请求的“创建”方法。 I made an overloaded method "createEmpty()" in order to try something, but later deleted as it throwed a org.springframework.beans.factory.BeanCreationException for ambiguous mapping. 为了尝试尝试,我制作了一个重载方法“ createEmpty()”,但后来删除了该方法,因为它抛出了org.springframework.beans.factory.BeanCreationException以进行模糊映射。

The problem is that after I deleted said method, I still get the exception. 问题是删除了上述方法后,我仍然得到异常。

@Controller
public class ListsController {

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

INFO: Dev App Server is now running may 04, 2014 4:21:34 PM com.google.apphosting.utils.jetty.JettyLogger warn WARNING: /: javax.servlet.UnavailableException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; 信息:Dev App Server现在正在运行,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的初始化失败; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. 嵌套的异常是java.lang.IllegalStateException:找到了模糊的映射。 Cannot map 'listsController' bean method public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() to {[/lists],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'listsController' bean method public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs.tp.list_sharer.domain.List) mapped. 无法将“ listsController” bean方法公共tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty()映射到{[/ lists],方法= [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)映射。 may 04, 2014 4:21:34 PM com.google.apphosting.utils.jetty.JettyLogger warn WARNING: /: javax.servlet.UnavailableException: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0': Initialization of bean failed; 2014年5月4日下午4:21:34 com.google.apphosting.utils.jetty.JettyLogger警告警告:/:javax.servlet.UnavailableException:org.springframework.beans.factory.BeanCreationException:创建名称为“ org”的bean时出错。 springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping#0':Bean初始化失败; nested exception is java.lang.IllegalStateException: Ambiguous mapping found. 嵌套的异常是java.lang.IllegalStateException:找到了模糊的映射。 Cannot map 'listsController' bean method public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty() to {[/lists],methods=[POST],params=[],headers=[],consumes=[],produces=[],custom=[]}: There is already 'listsController' bean method public tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.create(tacs.tp.list_sharer.domain.List) mapped. 无法将“ listsController” bean方法公共tacs.tp.list_sharer.domain.List tacs.tp.list_sharer.web.ListsController.createEmpty()映射到{[/ lists],方法= [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)映射。

It seems that createEmpty() is cached somewhere... 似乎createEmpty()缓存在某处...

Please try to do: 请尝试做:
1. If you are using eclipse - Project -> Clean. 1.如果您使用的是Eclipse-Project-> Clean。
2. If you are using maven try to clean and/or install project before deploying. 2.如果使用的是maven,请尝试在部署之前清理和/或安装项目。



I see you are using Jetty, maybe these links will help to solve your problems: 我看到您正在使用Jetty,也许这些链接将有助于解决您的问题:
Cleaning up Jetty - Removing 'unnecessaries' things 清理码头-去除“不必要”的东西
Jetty runs old war altought mvn clean is run 码头运行旧战争alt mvn清洁运行

我在两个不同的控制器中具有相同的@RequestMapping值,我从其中一个控制器中删除了它,并且开始正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM