【发布时间】:2016-11-27 17:01:12
【问题描述】:
我正在使用maven,eclipse。从eclipse运行时一切都很好。 但是,如果我在 tomcat 上部署,它会返回 http 状态 404。 日志说没有在类路径上检测到 Spring WebApplicationInitializer 类型,但我正在使用 web.xml
我无法在这里找出问题,如果有人可以提供帮助。 过滤器和 servlet 映射没有问题。
web.xml
上下文类 org.springframework.web.context.support.AnnotationConfigWebApplicationContext
<!-- Location of Java @Configuration classes that configure the components
that makeup this application -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>com.asuare.temapp</param-value>
</context-param>
<context-param>
<param-name>org.atmosphere.cpr.sessionSupport</param-name>
<param-value>true</param-value>
</context-param>
<!-- Specifies the default mode of this application, to be activated if
no other profile (or mode) is specified -->
<context-param>
<param-name>spring.profiles.default</param-name>
<param-value>mysql</param-value>
</context-param>
<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Secures the application -->
安全过滤器 org.springframework.web.filter.DelegatingFilterProxy 目标豆名 springSecurityFilterChain 真的
<filter-mapping>
<filter-name>securityFilter</filter-name>
<url-pattern>/*</url-pattern>
<async-supported>true</async-supported>
</filter-mapping>
<!-- Handles requests into the application -->
<servlet>
<servlet-name>temapp</servlet-name>
<servlet-class>org.atmosphere.cpr.MeteorServlet</servlet-class>
<async-supported>true</async-supported>
<init-param>
<param-name>org.atmosphere.servlet</param-name>
<param-value>org.springframework.web.servlet.DispatcherServlet</param-value>
</init-param>
<!-- No explicit configuration file reference here: everything is configured
in the root container for simplicity -->
<init-param>
<param-name>contextClass</param-name>
<param-value>org.springframework.web.context.support.AnnotationConfigWebApplicationContext
</param-value>
</init-param>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value></param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>temapp</servlet-name>
<url-pattern>/</url-pattern>
<async-supported>true</async-supported>
</servlet-mapping>
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>FORWARD</dispatcher>
<dispatcher>REQUEST</dispatcher>
<async-supported>true</async-supported>
</filter-mapping>
<error-page>
<error-code>403</error-code>
<location>/denied</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/restapi/denied</location>
</error-page>
服务器日志:
2016 年 7 月 24 日 13:20:57.816 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 没有春天 在类路径上检测到 WebApplicationInitializer 类型 2016 年 7 月 24 日 13:20:58.331 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 初始化 Spring 根 WebApplicationContext 2016 年 7 月 24 日 13:21:25.913 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 初始化 Spring FrameworkServlet 'sportsEasy' 2016 年 7 月 24 日 13:21:42.699 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 没有春天 在类路径上检测到 WebApplicationInitializer 类型 2016 年 7 月 24 日 13:22:02.971 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 没有春天 在类路径上检测到 WebApplicationInitializer 类型 2016 年 7 月 24 日 13:22:03.034 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 2016 年 7 月 24 日 13:22:03.034 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 会话监听器: contextInitialized() 2016 年 7 月 24 日 13:22:48.611 信息 [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log 没有春天 在类路径上检测到 WebApplicationInitializer 类型
【问题讨论】:
-
你用的是spring-boot吗?
-
不使用spring-boot。
-
是的,我尝试过全新安装、构建、进程类..
-
你能发布你的 web.xml 和你的 pom.xml 吗?
-
您的
/ 没有触发 Dispatcherservlet,因为 -temapp- 指向其他类。不是 100% sur,但您应该考虑这方面。
标签: java eclipse spring tomcat spring-security