启动某个项目的时候显示端口被占用
例如启动jar包时显示以下报错信息:
Error starting ApplicationContext. To display the conditions report re-run your application with ‘debug’ enabled.
The Tomcat connector configured to listen on port 8899 failed to start. The port may already be in use or the connector may be misconfigured.
1.查看端口占用情况:
输入 netstat -ano 查看端口占用情况
记得在报错的地方看看是什么端口被占用,我这边是8899端口被占用。
找到被占用的端口,确认端口已被占用
2.通过端口号找进程ID
lsof -i:端口号
比如: lsof -i:8899
找到PID
输入kill -9 进程id
例如kill -9 20051
结束进程,结束之前一定要再三确认进程id,不要弄错
结束之后再重试即可