Spring root WebApplicationContext 未在 eclipse 中初始化



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

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 FilesJavajre7bin;C:WindowsSunJavabin;C:Windowssystem32;C:Windows;C:Program Files (x86)InteliCLS Client;C:Program FilesInteliCLS Client;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:Program FilesHewlett-PackardSimplePass;C:Program Files (x86)Windows LiveShared;C:Program FilesIntelIntel(R) Management Engine ComponentsDAL;C:Program FilesIntelIntel(R) Management Engine ComponentsIPT;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsDAL;C:Program Files (x86)IntelIntel(R) Management Engine ComponentsIPT;c:Program Files (x86)Microsoft SQL Server100ToolsBinn;c:Program FilesMicrosoft SQL Server100ToolsBinn;c:Program FilesMicrosoft SQL Server100DTSBinn;c:Program Files (x86)Microsoft SQL Server100ToolsBinnVSShellCommon7IDE;c:Program Files (x86)Microsoft SQL Server100DTSBinn;C:Program FilesJavajdk1.7.0_51bin;C:Program FilesApache Software Foundationapache-maven-3.2.3bin;.
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:Usershp1workspace.metadata.pluginsorg.eclipse.wst.server.coretmp1wtpwebappsSpringMVCHibernateWEB-INFlibjsp-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:Usershp1workspace.metadata.pluginsorg.eclipse.wst.server.coretmp1wtpwebappsSpringMVCHibernateWEB-INFlibservlet-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    

我将它与另一个应用程序进行了比较,发现在类路径上检测到以下文本后是预期的

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全新安装,然后将其部署到tomcat/webapps中,它运行良好,但在日食上却不行。知道吗?可能是什么原因?

网络.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 内容的自定义 Web 根文件夹时。在这种情况下,必须更新部署程序集。

看这里: https://stackoverflow.com/a/57298082/1005607

最新更新