1. 程式人生 > >在eclipse中執行web專案埠號被佔用

在eclipse中執行web專案埠號被佔用

在eclipse中啟動Tomcat出現錯誤提示:

Several ports (8005, 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).

1.Tomcat伺服器在終端啟動

linux下命令列sudo sh shutdown.sh 關閉Tomcat伺服器

2.埠被其他程序佔用

linux下:
sudo lsof -i :8080
sudo lsof -i :8005
sudo lsof -i :8009

檢視佔用埠的程序以及程序號pid,這裡需要使用超級管理員許可權sudo,不加sudo可能顯示不出來

殺死該程序:sudo kill -9 pid

3.沒有在server標籤中或者是jsp頁面中啟動server

4.Process標籤中還有其他未終止的程序

解決辦法:

1.把佔用埠號的程式關掉
在執行輸入cmd

輸入命令netstat -ano|findstr “8080”,檢視8080埠是否被佔用,且得到了程序號“3084”;
再輸入命令tasklist|findstr “3084”,得到程序映像名javaw.exe;
啟動工作管理員,結束javaw.exe程序;
最後再輸入命令netstat -ano|findstr “8080”,檢視8080埠是否被還佔用
在這裡插入圖片描述
2.更改埠號
在 Eclipse 裡面找到 Servers,看到有許多配置檔案
開啟server.xml 配置檔案:
找到配置埠號的地方:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>


修改 port=‘8888’ , 儲存檔案

<Connector connectionTimeout="20000" port="8888" protocol="HTTP/1.1" redirectPort="8443"/>