mac下解决tomcat端口被站用问题

有时候运行程序总会报如下错误:

Several ports (8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. The server may already be running in another process, or a system process may be using the port. To start this server you will need to stop the other process or change the port number(s).

解决方法:

一、查看站用端口号的进程号

命令:lsof -i :<端口号>
例如:

root$ lsof -i :8080
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
java    48168   root   54u  IPv6 0x2a670557f4dd04dd      0t0  TCP *:http-alt (LISTEN)

二、杀死站用指定端口号的进程

命令:kill -9 <进程ID>
例如:kill -9 48168

三、重新运行tomcat或者项目

你可能感兴趣的:(Java)