gpt4 book ai didi

在 tomcat 上部署后未加载 Spring 上下文

转载 作者:行者123 更新时间:2023-11-28 22:27:51 25 4
gpt4 key购买 nike

我正在尝试在部署 war 时加载 spring batch 作业上下文文件。

我已经添加了 contextConfigLocation 如下但没有工作。甚至在 pom.xml 中添加了 spring-web 但是当我将我的 war 应用程序部署到 tomcat spring 时仍然没有被初始化。请帮助我,因为我已经提到了大部分 SO 和spring 论坛的答案,我不想使用调度程序 servlet,因为到目前为止这不是一个 web 应用程序。它只是一个批处理作业,但将来它将是一个批处理作业 + web 应用程序,那时我将有一个调度程序 servlet .请让我知道如何在服务器启动时加载 Spring 。

存在完整代码的我的 git 存储库 https://github.com/sumateja/patternfinder https://github.com/sumateja/patternfinder.git

tomcat 日志

Dec 25, 2015 12:20:59 AM 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\jdk1.7.0_45\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\ProgramData\Oracle\Java\javapath;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\Program Files (x86)\AMD APP\bin\x86_64;C:\Program Files (x86)\AMD APP\bin\x86;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Program Files (x86)\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Live\Shared;C:\Program Files (x86)\ATI Technologies\ATI.ACE\Core-Static;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\Java\jdk1.7.0_45\bin;C:\Development\apache-maven-3.1.1\bin;C:\Program Files\nodejs\;C:\Program Files (x86)\Skype\Phone\;C:\Program Files\MySQL\MySQL Enterprise Backup 3.12\;C:\Program Files\Git\cmd;C:\Ruby21-x64\bin;C:\Users\Tejas\AppData\Local\Programs\Python\Python35-32\Scripts\;C:\Users\Tejas\AppData\Local\Programs\Python\Python35-32\;C:\Users\Tejas\AppData\Local\Programs\Python\Launcher\;C:\Users\Tejas\AppData\Roaming\npm;C:\Program Files\Git\bin;.
Dec 25, 2015 12:20:59 AM org.apache.tomcat.util.digester.SetPropertiesRule begin
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting property 'source' to 'org.eclipse.jst.jee.server:patternfinder' did not find a matching property.
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-9090"]
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-9009"]
Dec 25, 2015 12:20:59 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 548 ms
Dec 25, 2015 12:20:59 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
Dec 25, 2015 12:20:59 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.47
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-9090"]
Dec 25, 2015 12:20:59 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-9009"]
Dec 25, 2015 12:20:59 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 547 ms

网络.xml

<web-app version="3.0" 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_3_0.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:equity-eod-job.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

最佳答案

我在我的机器上克隆了你的项目。我做了“mvn clean package”。当我准备将 war 文件从 target 文件夹复制到 tomcat webapps 文件夹时,我注意到您将其打包为 jar 而不是 war。 :)

更改您的 pom.xml,从 jar 到 war 的包装值:

    <modelVersion>4.0.0</modelVersion>
<groupId>patternfinder</groupId>
<artifactId>patternfinder</artifactId>
<packaging>war</packaging> <!-- This line from jar to war-->
<version>1.0</version>
<name>patternfinder</name>

之后做:

  1. mvn 清理包
  2. 复制target/patternfinder-1.0.war到tomcat webapp文件夹
  3. 启动tomcat

现在您可以看到您的应用程序将开始加载。似乎有一个错误的文件路径,在日志中你可以发现 FileNotFoundException 发生。我希望你能解决这个问题。

关于在 tomcat 上部署后未加载 Spring 上下文,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34456991/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com