在 Eclipse Indigo 中使用 Spring MVC 3.2.0、Tomcat 7.0.27 启动我的 Web 应用程序时遇到问题。从昨天开始一切正常。但现在看来我的 Webapp 无法正确部署。
...
Jan 06, 2013 12:04:49 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 477 ms
Jan 06, 2013 12:04:49 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 06, 2013 12:04:49 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27
Jan 06, 2013 12:04:50 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 06, 2013 12:04:51 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 06, 2013 12:04:51 PM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory <...>.metadata\.plugins\org.eclipse.wst.server.core\tmp0\webapps\...
Jan 06, 2013 12:04:52 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-80"]
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 06, 2013 12:04:52 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 06, 2013 12:04:52 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2800 ms
只有消息
信息:在类路径上未检测到 Spring WebApplicationInitializer 类型
我觉得部署 webapp 有问题
当我调用 URL
本地主机:8080/myWebApp
我只看到目录列表
我做了什么:我source
从我的 webApp 中删除了我的属性,server.xml
我/WEB-INF/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">
<!-- Processes application requests -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
</web-app>
我将 servlet-definition 放入/WEB-INF
其中,它看起来像这样:
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:jms="http://www.springframework.org/schema/jms"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd
http://www.springframework.org/schema/jms
http://www.springframework.org/schema/jms/spring-jms.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://activemq.apache.org/schema/core
http://activemq.apache.org/schema/core/activemq-core.xsd">
<context:component-scan base-package="net.tud.vorlesung" />
<mvc:annotation-driven />
</beans>