首页 > 解决方案 > 为什么 Tomcat 不在 EC2 上启动 Spring-boot 应用程序?

问题描述

昨天我启动了具有新功能的 Spring-boot 应用程序,但我的应用程序没有启动。catalina.out 中只有普通日志,除了 WARNING 日志,这说明我 Tomcat 8 将使用默认 xml 版本而不是指定我的:

 21-Sep-2020 16:46:33.348 INFO [http-nio-8080-exec-65] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/share/tomcat9/webapps/mobile-app-ws-0.0.1-SNAPSHOT.war]
21-Sep-2020 16:46:43.484 WARNING [http-nio-8080-exec-65] org.apache.tomcat.util.descriptor.web.WebXml.setVersion Unknown version string [4.0].Default version will be used .
21-Sep-2020 16:46:33.348 INFO [http-nio-8080-exec-65]  org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
21-Sep-2020 16:46:43.622 INFO [http-nio-8080-exec-65] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/share/tomcat9/webapps/mobile-app-ws-0.0.1-SNAPSHOT.war] has finished in [10,272] ms
                       

这是由 Tomcat 8 使用 xml 版本 3.1 引起的,但在我的 pom.xml 中设置为 4.0。所以我选择在我的 Linux 服务器上安装 Tomcat 9。我在想我的应用程序没有启动,因为我的 pom.xml 中的默认 Tomcat XML 版本和 XML 版本之间存在冲突。所以,我在这里。在 Tomcat 9 上,同样的简单日志并没有任何线索表明出了什么问题:

22-Sep-2020 16:46:33.348 INFO [http-nio-8080-exec-65] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/usr/share/tomcat9/webapps/mobile-app-ws-0.0.1-SNAPSHOT.war]
22-Sep-2020 16:46:43.484 INFO [http-nio-8080-exec-65] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
22-Sep-2020 16:46:43.622 INFO [http-nio-8080-exec-65] org.apache.catalina.startup.HostConfig.deployWAR Deployment of web application archive [/usr/share/tomcat9/webapps/mobile-app-ws-0.0.1-SNAPSHOT.war] has finished in [10,272] ms.

在我的本地计算机上,我在部署期间有以下日志:

22-Sep-2020 19:46:49.238 INFO [main] org.apache.catalina.core.StandardEngine.startInternal Starting Servlet engine: [Apache Tomcat/9.0.37]
22-Sep-2020 19:46:49.253 INFO [main] org.apache.catalina.startup.HostConfig.deployWAR Deploying web application archive [/home/etniqa/etniqa/utilities/apache-tomcat-9.0.37/webapps/mobile-app-ws-0.0.1-SNAPSHOT.war]
22-Sep-2020 19:46:58.919 INFO [main] org.apache.jasper.servlet.TldScanner.scanJars At least one JAR was scanned for TLDs yet contained no TLDs. Enable debug logging for this logger for a complete list of JARs that were scanned but no TLDs were found in them. Skipping unneeded JARs during scanning can improve startup time and JSP compilation time.
SOUT INTO MAIN CLASS INTO INIT-STATIC SNIPPET
22-Sep-2020 19:46:59.051 INFO [main] com.example.mobileappws.MobileAppWsApplication.<clinit> LOG INTO MAIN CLASS INTO INIT-STATIC SNIPPET

  .   ____          _            __ _ _
 /\\ / ___'_ __ _ _(_)_ __  __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
 \\/  ___)| |_)| | | | | || (_| |  ) ) ) )
  '  |____| .__|_| |_|_| |_\__, | / / / /
 =========|_|==============|___/=/_/_/_/
 :: Spring Boot ::        (v2.3.1.RELEASE)

2020-09-22 19:47:00.952  INFO 19842 --- [           main] c.e.mobileappws.MobileAppWsApplication   : Starting MobileAppWsApplication v0.0.1-SNAPSHOT on etniqa with PID 19842 (/home/etniqa/etniqa/utilities/apache-tomcat-9.0.37/webapps/mobile-app-ws-0.0.1-SNAPSHOT/WEB-INF/classes started by etniqa in /home/etniqa/etniqa/utilities/apache-tomcat-9.0.37/bin)

它工作得很好。

一周前我遇到了类似的问题。然后我在 pom.xml 中设置了 JDK 8 的版本:

<properties>
    <java.version>1.8</java.version>
</properties>

我的 Linux 服务器上的版本:JDK:

openjdk 版本“1.8.0_265”

雄猫:

服务器版本:Apache Tomcat/9.0.38

标签: springspring-boottomcatloggingamazon-ec2

解决方案


推荐阅读