Mac下Eclipse内置Tomcat端口被占用问题的解决办法

一直使用Mac做开发,偶然一次启动Mac中eclipse中的tomcat时报错:

1
2
3
4
5
6
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).

在网上查找资料大多是Windows上解决的办法!
现在说一说Mac下的解决的办法:

  • 打开终端,确定被占用的端口号,输入以下命令:

    1
    lsof -i :8080
  • 该命令会输出下图所示内容:

Snip20161116_2.png

  • 我的电脑上被占用8080端口的进程ID是698,所以干掉这个进程就OK了

    1
    kill -9 698
  • 根据你的进程ID更改最后的一个参数,在终端输入后回车,然后重启Eclipse,tomcat可以正常启动了!