简体   繁体   English

Spring应用程序在Eclipse中工作,但在tomcat 8上部署时无法正常工作

[英]Spring application working in eclipse but same not working when deployed on tomcat 8

I am using maven, eclipse. 我正在使用Maven,Eclipse。 Everything is fine when running from eclipse. 从Eclipse运行时一切正常。 But same if I deploy on tomcat it returns http status 404. log says No Spring WebApplicationInitializer types detected on classpath but I am using web.xml 但是同样,如果我在tomcat上部署,它将返回http状态404。日志显示在类路径上未检测到Spring WebApplicationInitializer类型,但我使用的是web.xml

I am not able to figure out issue here, if anybody can help please. 如果有人可以帮助,我在这里无法解决问题。 There is no issue with filter and servlet mapping. 过滤器和servlet映射没有问题。

web.xml web.xml

contextClass org.springframework.web.context.support.AnnotationConfigWebApplicationContext 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 true securityFilter org.springframework.web.filter.DelegatingFilterProxy targetBeanName springSecurityFilterChain true

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

server log: 服务器日志:

24-Jul-2016 13:20:57.816 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:20:58.331 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring root WebApplicationContext 24-Jul-2016 13:21:25.913 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log Initializing Spring FrameworkServlet 'sportingEasy' 24-Jul-2016 13:21:42.699 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:22:02.971 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath 24-Jul-2016 13:22:03.034 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log ContextListener: contextInitialized() 24-Jul-2016 13:22:03.034 INFO [localhost-startStop-1] org.a 2016年7月24日13:20:57.816 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型24-Jul-2016 13:20:58.331 INFO [localhost- startStop-1] org.apache.catalina.core.ApplicationContext.log初始化Spring根WebApplicationContext 2016年7月24日13:21:25.913 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log初始化Spring FrameworkServlet'sportingEasy'2016年7月24日13:21:42.699信息[localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型2016年7月24日13:22:02.971 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型2016年7月24日13:22:03.034 INFO [localhost-startStop-1] org.apache.catalina。 core.ApplicationContext.log ContextListener:contextInitialized()2016年7月24日13:22:03.034 INFO [localhost-startStop-1] org.a pache.catalina.core.ApplicationContext.log SessionListener: contextInitialized() 24-Jul-2016 13:22:48.611 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log No Spring WebApplicationInitializer types detected on classpath pache.catalina.core.ApplicationContext.log SessionListener:contextInitialized()2016年7月24日13:22:48.611 INFO [localhost-startStop-1] org.apache.catalina.core.ApplicationContext.log在类路径上未检测到Spring WebApplicationInitializer类型

I also had the same problem. 我也有同样的问题。 My maven had tomcat7 plugin but the JRE environment was 1.6. 我的maven有tomcat7插件,但JRE环境是1.6。 I changed my tomcat7 to tomcat6 and the error was gone.Could you check once your JRE environment and try. 我将tomcat7更改为tomcat6,错误消失了。您能否检查一下JRE环境并尝试一下。 Also please add the 'maven-war-plugin' version 2.6 in your pom.xml 另外,请在pom.xml中添加“ maven-war-plugin” 2.6版

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

相关问题 Spring 启动 REST 应用程序部署为 tomcat 上的 WAR 不工作 - Spring boot REST application deployed as WAR on tomcat is not working 为什么Spring Security在Tomcat中可以工作,而在部署到Weblogic时却不能工作? - Why is Spring Security working in Tomcat but not when deployed to Weblogic? 部署在Tomcat上的SpringBoot MVC应用程序无法正常工作 - SpringBoot MVC application deployed on Tomcat wont working 在 Eclipse 中部署到 Tomcat 时,Spring Boot 应用程序不会启动 - Spring Boot application doesn't start when deployed to Tomcat inside Eclipse AOP(不带Spring)不适用于Tomcat,但适用于Eclipse - AOP (without Spring) not working on Tomcat but Eclipse 在tomcat中部署了Spring Boot Application - Deployed Spring boot Application in tomcat Spring Web Reactive 无法作为部署在 Tomcat 8.5 上的 war 文件工作 - Spring Web Reactive not working as war file deployed on Tomcat 8.5 在TomCat上部署时,我的Angular + Spring应用程序路由不起作用 - My Angular + Spring Application routing does not work when deployed on TomCat Spring Boot应用程序可以独立运行,但是在Tomcat中部署时找不到类 - Spring Boot application works as standalone but class not found when deployed in Tomcat 部署到 Tomcat 时无法访问基本 REST Spring MVC 应用程序 - Basic REST Spring MVC application cannot be reached when deployed to Tomcat
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM