Tomcat启动springboot项目war包报错:启动子级时出错的问题

首先,当我们将 SpringBoot 项目打包成 war 文件并上传到 Tomcat,启动时可能会出现以下错误提示:

org.springframework.context.ApplicationContextException: Unable to start web server; nested exception is org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:156)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:544)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:173)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:153)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:95)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5128)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1025)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1895)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:824)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1601)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:456)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:88)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:409)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
    ... 10 common frames omitted
Caused by: org.springframework.boot.web.server.WebServerException: Unable to start embedded Tomcat
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:229)
    at org.springframework.boot.web.servlet.context.WebServerStartStopLifecycle.start(WebServerStartStopLifecycle.java:43)
    at org.springframework.context.support.DefaultLifecycleProcessor.doStart(DefaultLifecycleProcessor.java:178)
    at org.springframework.context.support.DefaultLifecycleProcessor.access$200(DefaultLifecycleProcessor.java:54)
    at org.springframework.context.support.DefaultLifecycleProcessor$LifecycleGroup.start(DefaultLifecycleProcessor.java:356)
    at org.springframework.context.support.DefaultLifecycleProcessor.startBeans(DefaultLifecycleProcessor.java:157)
    at org.springframework.context.support.DefaultLifecycleProcessor.onRefresh(DefaultLifecycleProcessor.java:121)
    at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:885)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.finishRefresh(ServletWebServerApplicationContext.java:162)
    at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:141)
    at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:747)
    at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:405)
    at org.springframework.boot.SpringApplication.run(SpringApplication.java:315)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.run(SpringBootServletInitializer.java:173)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.createRootApplicationContext(SpringBootServletInitializer.java:153)
    at org.springframework.boot.web.servlet.support.SpringBootServletInitializer.onStartup(SpringBootServletInitializer.java:95)
    at org.springframework.web.SpringServletContainerInitializer.onStartup(SpringServletContainerInitializer.java:171)
    at org.apache.catalina.core.StandardContext.startInternal(StandardContext.java:5128)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:713)
    at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:690)
    at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:695)
    at org.apache.catalina.startup.HostConfig.deployWAR(HostConfig.java:1025)
    at org.apache.catalina.startup.HostConfig$DeployWar.run(HostConfig.java:1895)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at org.apache.tomcat.util.threads.InlineExecutorService.execute(InlineExecutorService.java:75)
    at java.util.concurrent.AbstractExecutorService.submit(AbstractExecutorService.java:112)
    at org.apache.catalina.startup.HostConfig.deployWARs(HostConfig.java:824)
    at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:474)
    at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1601)
    at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:324)
    at org.apache.catalina.util.LifecycleBase.fireLifecycleEvent(LifecycleBase.java:123)
    at org.apache.catalina.util.LifecycleBase.setStateInternal(LifecycleBase.java:423)
    at org.apache.catalina.util.LifecycleBase.setState(LifecycleBase.java:366)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:936)
    at org.apache.catalina.core.StandardHost.startInternal(StandardHost.java:871)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.ContainerBase.startInternal(ContainerBase.java:928)
    at org.apache.catalina.core.StandardEngine.startInternal(StandardEngine.java:262)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardService.startInternal(StandardService.java:421)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.core.StandardServer.startInternal(StandardServer.java:930)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:183)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:456)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.initialize(TomcatWebServer.java:107)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.<init>(TomcatWebServer.java:88)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getTomcatWebServer(TomcatServletWebServerFactory.java:409)
    at org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory.getWebServer(TomcatServletWebServerFactory.java:174)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.createWebServer(ServletWebServerApplicationContext.java:181)
    at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.onRefresh(ServletWebServerApplicationContext.java:154)
    ... 10 common frames omitted
Caused by: org.apache.catalina.LifecycleException: Failed to start component [StandardServer[-1]]
    at org.apache.catalina.util.LifecycleBase.handleSubClassException(LifecycleBase.java:440)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:198)
    at org.apache.catalina.startup.Tomcat.start(Tomcat.java:436)
    at org.springframework.boot.web.embedded.tomcat.TomcatWebServer.start(TomcatWebServer.java:203)
    ... 54 common frames omitted
Caused by: java.net.BindException: Address already in use: bind
    at sun.nio.ch.Net.bind0(Native Method)
    at sun.nio.ch.Net.bind(Net.java:461)
    at sun.nio.ch.Net.bind(Net.java:453)
    at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:222)
    at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:85)
    at org.apache.tomcat.util.net.NioEndpoint.initServerSocket(NioEndpoint.java:228)
    at org.apache.tomcat.util.net.NioEndpoint.bind(NioEndpoint.java:211)
    at org.apache.tomcat.util.net.AbstractEndpoint.bindWithCleanup(AbstractEndpoint.java:1141)
    at org.apache.tomcat.util.net.AbstractEndpoint.init(AbstractEndpoint.java:1154)
    at org.apache.tomcat.util.net.NioEndpoint.init(NioEndpoint.java:220)
    at org.apache.coyote.AbstractProtocol.init(AbstractProtocol.java:623)
    at org.apache.coyote.http11.AbstractHttp11Protocol.init(AbstractHttp11Protocol.java:68)
    at org.apache.catalina.connector.Connector.initInternal(Connector.java:1056)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.core.StandardService.initInternal(StandardService.java:552)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.core.StandardServer.initInternal(StandardServer.java:1059)
    at org.apache.catalina.util.LifecycleBase.init(LifecycleBase.java:136)
    at org.apache.catalina.util.LifecycleBase.start(LifecycleBase.java:173)
    ... 56 common frames omitted

这是因为 Tomcat 启动时端口被占用了。我们需要先关闭对应端口的进程,或者更改 Tomcat 的启动端口。

下面是两个示例:

  1. 找到占用 Tomcat 端口的进程 ID,然后关闭进程:
$ netstat -ano | grep "8080"
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      22377/java
$ kill -9 22377
  1. 更改 Tomcat 启动端口:

找到 <TomcatHome>/conf/server.xml 文件,修改以下内容:

<Connector port="8080" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

改成:

<Connector port="8888" protocol="HTTP/1.1"
               connectionTimeout="20000"
               redirectPort="8443" />

重启 Tomcat 就行了。

希望能帮到你!

本站文章如无特殊说明,均为本站原创,如若转载,请注明出处:Tomcat启动springboot项目war包报错:启动子级时出错的问题 - Python技术站

(0)
上一篇 2023年5月20日
下一篇 2023年5月20日

相关文章

  • mall整合SpringSecurity及JWT实现认证授权实战

    来分享一下“mall整合SpringSecurity及JWT实现认证授权实战”的完整攻略。 1. 环境准备 要完成该攻略,首先需要准备好以下环境: JDK 1.8+ Maven 3.x IntelliJ IDEA 2019.2+(或其他任意IDE) 2. 创建maven项目 使用maven创建一个空白的Spring Boot项目,并引入必要的依赖,包括Spr…

    Java 2023年5月20日
    00
  • jquery ajax 局部刷新小案例

    首先,让我们了解一下jQuery的ajax方法,该方法允许我们通过JavaScript代码向服务器发送异步HTTP请求,并在服务器响应事件时更新部分页面内容,使得页面刷新更快,用户体验更加顺畅。 接下来,我们将介绍一个jquery ajax的小案例,以帮助您更好地理解如何使用jQuery和ajax来实现局部刷新。 一、案例需求 我们的网站有一个评论区,用户可…

    Java 2023年6月15日
    00
  • 通过button将form表单的数据提交到action层的实例

    以下是通过button将form表单的数据提交到action层的攻略: 1. 编写HTML代码 首先,我们需要编写一个HTML表单,包含要提交的数据和一个提交按钮。例如: <form action="/submit" method="POST"> <label for="name"…

    Java 2023年6月15日
    00
  • 鼠标焦点离开文本框时验证的js代码

    当用户在网页中填写表单时,我们常常需要验证用户输入的数据是否合法。而当用户在输入框输入完内容后,离开这个输入框,我们需要验证这个输入框中的内容是否符合我们的要求,这时候我们就需要使用JavaScript代码来验证用户的输入。以下是实现鼠标焦点离开文本框时验证的js代码的完整攻略。 1. 绑定事件 我们需要先为输入框绑定一个事件,当输入框失去焦点时触发这个事件…

    Java 2023年6月15日
    00
  • Spring Security前后分离校验token的实现方法

    我会详细讲解“Spring Security前后分离校验token的实现方法”的完整攻略。这里将分为以下几个步骤: 获得token 将token保存到请求头中 在后端进行token校验 返回结果给前端 下面我们具体来看一下每一步的实现方法。 1. 获得token 首先,我们需要在前端登录成功之后,获得token。我们可以通过发送登录请求来获取token,例如…

    Java 2023年5月20日
    00
  • 解决Jackson解析嵌套类问题(MismatchedInputException)

    解决Jackson解析嵌套类问题(MismatchedInputException)可以分为以下几个步骤: 1. 确认报错信息 在开始处理问题之前,我们首先需要确认MismatchedInputException报错信息的内容,以便能够更加准确地定位问题和解决问题。报错信息通常包含以下关键信息: 错误原因:报错信息说明了当前出现了什么错误; 错误位置:报错信…

    Java 2023年5月26日
    00
  • 深入理解Java8新特性之Lambda表达式的基本语法和自定义函数式接口

    深入理解Java8新特性之Lambda表达式的基本语法和自定义函数式接口 1. Lambda表达式的基本语法 Lambda表达式是一种匿名函数,可以在Java8及以后版本中使用。它可以将函数作为方法参数,或者将其作为数据来处理。 Lambda表达式的基本语法如下: (parameter1, parameter2, …, parameterN) ->…

    Java 2023年5月26日
    00
  • 关于java方法区详解

    Java方法区详解 在Java虚拟机中,方法区是一块被线程共享的内存区域,用于存储类、常量、静态变量、即时编译器编译后的代码等数据。本文将详细介绍Java方法区的相关知识。 方法区的作用 方法区主要用于存储类相关的数据,具体包括以下内容: 1.类信息:类的完全限定名、父类的完全限定名、实现接口的完全限定名、类的修饰符等。 2.常量池:用于存储编译期生成的各种…

    Java 2023年5月20日
    00
合作推广
合作推广
分享本页
返回顶部