对不起,这是我已经问过的另一个问题:Spring MVC Rest: No mapping found for HTTP request with URI [/ecommerce-api/rest/checkout] in DispatcherServlet
但我生气了,因为问题再次出现了。当一切似乎突然停止时,它会停止: - (
我正在尝试使用SpringMVC构建API,我正在使用STS 3.3.0开发并使用其余的shell 1.2.1进行测试。
我发出的命令是:
获取电子商务-api / rest / checkout
我得到的错误是:
2013-09-10 11:56:49,614 DEBUG [tomcat-http - 9] servlet.DispatcherServlet(DispatcherServlet.java:823) - 名为“api-dispatcher”的DispatcherServlet处理GET请求 for [/ ecommerce-api / rest / checkout] 2013-09-10 11:56:49,615 DEBUG [tomcat-http - 9] handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:220) - 查找处理程序方法 for path / checkout 2013-09-10 11:56:49,615 DEBUG [tomcat-http - 9] handler.AbstractHandlerMethodMapping (AbstractHandlerMethodMapping.java:230) - 没有找到处理程序方法 for [/ checkout] 2013-09-10 11:56:49,615 WARN [tomcat-http - 9] servlet.DispatcherServlet(DispatcherServlet.java:1108) - 没有映射 找到带有URI [/ ecommerce-api / rest / checkout]的HTTP请求 DispatcherServlet,名称为“api-dispatcher”2013-09-10 11:56:49,615 DEBUG [tomcat-http - 9] servlet.FrameworkServlet (FrameworkServlet.java:966) - 已成功完成请求
直到昨天一切都工作得很好,今天早上我试图为我真正基本的控制器添加一些功能,我得到了上述错误。
我尝试的没有成功:
1)从git存储库恢复到最后一个工作版本
2)在干净的Tomcat安装中部署war包(试图避免任何与Eclipse相关的问题)
3)从STS中的vFabric取消发布包 - 清理其工作目录 - 清理项目 - 再次部署
我复制了我的* .xml和java文件,即使它们似乎没问题,因为它们几个小时前就已经有效了。
任何想法或建议都会非常感激。
沮丧的开发者(又名Alexio)。
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/application-context.xml
</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
<servlet>
<servlet-name>api-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/api-dispatcher-servlet.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>6</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>api-dispatcher</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>
<listener>
<listener-class>
org.springframework.web.context.request.RequestContextListener
</listener-class>
</listener>
</web-app>
API-dispatcher.xml
<?xml version="1.0" encoding="UTF-8" ?>
<beans:beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.fashionis.api.ecommerce.controller" />
<context:annotation-config />
<mvc:annotation-driven />
<import resource="classpath:/ecommerce-services-beans.xml"/>
</beans:beans>
checkoutcontroller.java
@Controller
@RequestMapping("/checkout")
public class CheckoutController {
private static final Logger logger = LoggerFactory.getLogger(CheckoutController.class);
@RequestMapping(method = RequestMethod.GET)
public @ResponseBody
Checkout getRandomCheckout() {
logger.debug("Before instantiating checkoutManager");
@SuppressWarnings("resource")
ConfigurableApplicationContext ctx = new ClassPathXmlApplicationContext("ecommerce-services-beans.xml");
CheckoutManager checkoutManager = ctx.getBean("checkoutManager", CheckoutManager.class);
logger.debug("Before asking for checkout");
Checkout checkout = checkoutManager
.findById("514f2a8e20f7a78a1400001f");
logger.debug("Checkout obtained. Con ID:" + checkout.getId());
return checkout;
}
}