问题|中断IDEA-端口被占用 @SpringBoot
问题描述:
背景:
- IEDA中,在SpringBoot项目还在运行状态时,突然关闭IDEA。
再次打开,并启动项目时,报端口错误
The Tomcat connector configured to listen on port 8080 failed to start.
具体:
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2021-01-05 12:55:36.879 ERROR 19848 --- [ restartedMain] o.s.b.d.LoggingFailureAnalysisReporter :
***************************
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.
2021-01-05 12:55:36.880 INFO 19848 --- [ restartedMain] ConfigServletWebServerApplicationContext : Closing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@4a97f566: startup date [Tue Jan 05 12:55:34 CST 2021]; root of context hierarchy
2021-01-05 12:55:36.882 INFO 19848 --- [ restartedMain] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
Process finished with exit code 0
原因分析:
原因:
- 8080端口被占用
说明:
- 自己在中途关闭IEDA时,选了Disconnect,导致没有终止进程,所以端口依旧在占用着
- 正确操作:选择Terminate → 关闭进程
解决方法:
想法:关闭端口
操作:查看进程
杀死进程
打开cmd(按 WIN+R键打开运行,输入cmd)
1.查看端口被谁占用-进程的Pid netstat -aon|findstr 【端口号】
2.window下强制杀死该进程 taskkill -f -pid 【进程号】
如:
netstat -aon|findstr 8080
taskkill -f -pid 20876
示例:
效果:再次启动SpringBoot项目
成功