(主要的)报错信息:
org.apache.catalina.LifecycleException: Failed to start component [Connector[HTTP/1.1-8080]]
……
……
***************************
APPLICATION FAILED TO START
***************************
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
原因:Tomcat端口被占用
可能是上次运行SpringBoot项目没有正常停止,造成对应的(访问8080端口的)进程还没有结束,造成8080端口被占用。
解决方法
既然Tomcat的8080端口被占用,我们可以关闭这个被占用的端口,或者是指定一个新的端口。
1.关闭占用8080端口的进程
打开cmd
1 .使用命令查看电脑端口的使用情况,找到使用8080端口的进程
netstat -aon | findstr 8080
注: netstat
命令参数解析: -a 显示所有连接和侦听端口。-o 显示拥有的与每个连接关联的进程 ID。-n 以数字形式显示地址和端口号。
这最后面的就是进程的id。
2 .关闭(杀死)该进程
2.1 使用命令行直接关闭,这里需要强制关闭,不然关闭不了。
taskkill /pid 2404 /f
注: taskkill
命令参数解析:/pid 指定要终止的进程的 PID。-f 强制关闭。
2.2 使用任务管理器关闭
根据进程id找到对应的进程,结束进程即可。
2.指定一个新的端口
在spring boot的配置文件application.properties中重新指定一个端口号(在该配置文件中加入下面一段代码即可)
server.port=8081
参考: