Spring根WebApplicationContext未在Eclipse中初始化 [英] Spring root WebApplicationContext not getting initialized in eclipse

查看:80
本文介绍了Spring根WebApplicationContext未在Eclipse中初始化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从下载了一个项目 http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial 我根据我的数据库环境配置它,当我在eclipse中启动server(tomcat)时,我面临的问题是.它开始了,但是应用程序没有开始. 我发现它没有提供初始化splrig根Web应用程序上下文的日志.启动时生成的日志是

I downloaded a project from http://www.journaldev.com/3531/spring-mvc-hibernate-mysql-integration-crud-example-tutorial I configured it according to my db env, Problem I am facing is, when I start the server(tomcat) in eclipse. It gets started but application doesn't get started. I found that it is not giving logs of initializing of splrig root webapplication context. Logs generated on start up are

Jan 13, 2015 10:34:52 PM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: C:\Program Files\Java\jre7\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Hewlett-Packard\SimplePass\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\Tools\Binn\;c:\Program Files\Microsoft SQL Server\100\DTS\Binn\;c:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;c:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Java\jdk1.7.0_51\bin;C:\Program Files\Apache Software Foundation\apache-maven-3.2.3\bin;.
Jan 13, 2015 10:34:52 PM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:SpringMVCHibernate' did not find a matching property.
Jan 13, 2015 10:34:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
Jan 13, 2015 10:34:52 PM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
Jan 13, 2015 10:34:52 PM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1269 ms
Jan 13, 2015 10:34:52 PM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Jan 13, 2015 10:34:52 PM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Jan 13, 2015 10:34:54 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\hp1\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SpringMVCHibernate\WEB-INF\lib\jsp-api-2.1.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/el/Expression.class
Jan 13, 2015 10:34:54 PM org.apache.catalina.loader.WebappClassLoader validateJarFile
INFO: validateJarFile(C:\Users\hp1\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\SpringMVCHibernate\WEB-INF\lib\servlet-api-2.5.jar) - jar not loaded. See Servlet Spec 2.3, section 9.7.2. Offending class: javax/servlet/Servlet.class
Jan 13, 2015 10:34:57 PM org.apache.catalina.core.ApplicationContext log
INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 13, 2015 10:34:57 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
Jan 13, 2015 10:34:57 PM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
Jan 13, 2015 10:34:57 PM org.apache.catalina.startup.Catalina start
INFO: Server startup in 4705 ms    

我将它与另一个应用程序进行了比较,发现在在类路径上检测到

I compared it with another application and found that below text was expected after the detected on classpath

INFO: No Spring WebApplicationInitializer types detected on classpath
Jan 13, 2015 10:37:55 PM org.apache.catalina.core.ApplicationContext log
INFO: Initializing Spring root WebApplicationContext
INFO : org.springframework.web.context.ContextLoader - Root WebApplicationContext: initialization started
INFO : org.springframework.web.context.support.XmlWebApplicationContext - Refreshing Root WebApplicationContext: startup date [Tue Jan 13 22:37:55 IST 2015]; root of context hierarchy
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/spring-security.xml]
INFO : org.springframework.beans.factory.xml.XmlBeanDefinitionReader - Loading XML bean definitions from ServletContext resource [/WEB-INF/appServlet-servlet.xml]

我还尝试了使用maven clean install的同一项目,然后将其部署在tomcat/webapps中,在这里它工作得很好,但是在eclipse上却没有.任何的想法?可能是什么原因?

Also I tried the same project with maven clean install and then deployed it in tomcat/webapps there it worked perfectly but not on eclipse. Any idea? What could be the reason ?

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

    <!-- The definition of the Root Spring Container shared by all Servlets and Filters -->
    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>/WEB-INF/spring/root-context.xml</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>

    <!-- Processes application requests -->
    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextConfigLocation</param-name>
            <param-value>/WEB-INF/spring/appServlet/servlet-context.xml</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

推荐答案

一个潜在的问题是当您拥有一个自定义的 Web Root 文件夹,该文件夹不是默认的/Web Content 时>.在这种情况下,必须更新部署程序集.

One potential issue is when you have a custom Web Root folder which is not the default /Web Content. In that case Deployment Assembly has to be updated.

请参阅此处: https://stackoverflow.com/a/57298082/1005607

这篇关于Spring根WebApplicationContext未在Eclipse中初始化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆