Spring应用程序在eclipse中工作但在tomcat 8

时间:2016-07-24 06:23:00

标签: java eclipse spring tomcat spring-security

我正在使用maven,eclipse。从日食运行时一切都很好。 但是如果我在tomcat上部署它会返回http状态404。 log表示在类路径上检测到没有Spring WebApplicationInitializer类型,但我使用的是web.xml

如果有人可以提供帮助,我无法在这里找出问题。 过滤器和servlet映射没有问题。

的web.xml

                  contextClass         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 -->

        SecurityFilter类         org.springframework.web.filter.DelegatingFilterProxy                      targetBeanName             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 INFO [localhost-startStop-1]   org.apache.catalina.core.ApplicationContext.log没有Spring   2016年7月24日在类路径上检测到的WebApplicationInitializer类型   13:20:58.331 INFO [localhost-startStop-1]   org.apache.catalina.core.ApplicationContext.log初始化Spring   root WebApplicationContext 24-Jul-2016 13:21:25.913 INFO   [本地主机 - startStop-1]   org.apache.catalina.core.ApplicationContext.log初始化Spring   FrameworkServlet'sportingEasy'24-Jul-2016 13:21:42.699 INFO   [本地主机 - startStop-1]   org.apache.catalina.core.ApplicationContext.log没有Spring   2016年7月24日在类路径上检测到的WebApplicationInitializer类型   13:22:02.971 INFO [localhost-startStop-1]   org.apache.catalina.core.ApplicationContext.log没有Spring   2016年7月24日在类路径上检测到的WebApplicationInitializer类型   13:22:03.034 INFO [localhost-startStop-1]   org.apache.catalina.core.ApplicationContext.log ContextListener:   contextInitialized()2016年7月24日13:22:03.034 INFO   [本地主机 - startStop-1]   org.apache.catalina.core.ApplicationContext.log SessionListener:   contextInitialized()2016年7月24日13:22:48.611信息   [本地主机 - startStop-1]   org.apache.catalina.core.ApplicationContext.log没有Spring   在类路径

上检测到的WebApplicationInitializer类型

1 个答案:

答案 0 :(得分:1)

我也有同样的问题。我的maven有tomcat7插件,但JRE环境是1.6。我将tomcat7更改为tomcat6,错误消失了。您可以检查一下JRE环境并尝试。 另外请在你的pom.xml中添加'maven-war-plugin'版本2.6