为了账号安全,请及时绑定邮箱和手机立即绑定

部署错误:Tomcat启动失败,服务器端口8080已在使用中

部署错误:Tomcat启动失败,服务器端口8080已在使用中

慕容3067478 2019-12-20 10:28:56
当我使用Netbeans运行Java项目时,出现以下错误:Deployment error:Starting of Tomcat failed, the server port 8080 is already in use.See the server log for details.        at org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment.deploy(Deployment.java:166)        at org.netbeans.modules.j2ee.ant.Deploy.execute(Deploy.java:104)        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:288)        at sun.reflect.GeneratedMethodAccessor619.invoke(Unknown Source)        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)        at java.lang.reflect.Method.invoke(Method.java:597)        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:105)        at org.apache.tools.ant.Task.perform(Task.java:348)        at org.apache.tools.ant.Target.execute(Target.java:357)        at org.apache.tools.ant.Target.performTasks(Target.java:385)        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1329)        at org.apache.tools.ant.Project.executeTarget(Project.java:1298)        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)        at org.apache.tools.ant.Project.executeTargets(Project.java:1181)        at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:277)        at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:460)        at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:151)Caused by: org.netbeans.modules.j2ee.deployment.impl.ServerException: Starting of Tomcat failed, the server port 8080 is already in use.        at org.netbeans.modules.j2ee.deployment.impl.ServerInstance._start(ServerInstance.java:1297)        ... 16 moreBUILD FAILED (total time: 4 seconds)我尝试在工具->服务器中将服务器端口更改为8081,并关闭端口。它运行正常,但是如果我执行任何操作并运行项目,则它再次显示“ 部署错误:Tomcat启动失败,服务器端口8081已在使用中 ”有什么问题吗?
查看完整描述

3 回答

?
冉冉说

TA贡献1877条经验 获得超1个赞

goto命令提示符


netstat -aon

对于Linux


netstat -tulpn | grep 'your_port_number'

它会向您显示类似


 TCP    192.1.200.48:2053      24.43.246.60:443       ESTABLISHED     248

 TCP    192.1.200.48:2055      24.43.246.60:443       ESTABLISHED     248

 TCP    192.1.200.48:2126      213.146.189.201:12350  ESTABLISHED     1308

 TCP    192.1.200.48:3918      192.1.200.2:8073       ESTABLISHED     1504

 TCP    192.1.200.48:3975      192.1.200.11:49892     TIME_WAIT       0

 TCP    192.1.200.48:3976      192.1.200.11:49892     TIME_WAIT       0

 TCP    192.1.200.48:4039      209.85.153.100:80      ESTABLISHED     248

 TCP    192.1.200.48:8080      209.85.153.100:80      ESTABLISHED     248

检查哪个进程绑定了您的端口。在上面的示例中,248如果您确定需要杀死该进程火,则为现在


Linux:


kill -9 248

视窗:


taskkill /f /pid 248

它会杀死那个过程


查看完整回答
反对 回复 2019-12-20
?
ITMISS

TA贡献1871条经验 获得超8个赞

如果在Linux上,您可以使用此脚本杀死现有的Tomcat。


#/bin/bash

if [ `whoami` != root ]; then

    echo "Please run this script as root or using sudo"

    exit

fi

echo

echo "finding proceses that have name java and established connections status"

echo

echo "Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name"

netstat --tcp  --programs  | grep "ESTABLISHED" | grep "java"

echo

echo "finding proceses that use port 8080 or http-alt"

echo

netstat --tcp --programs | grep ':8080\|:http-alt'

echo -n "Do you wish to kill a process listed above?[Y/n]"

read choose

if [ "$choose" = "Y" ] || [ "$choose" = "y" ] || [ -z "$choose" ]

then

echo "enter pid to kill"

read procesId

kill -9 $procesId

fi

echo "done exiting"

exit 0


查看完整回答
反对 回复 2019-12-20
  • 3 回答
  • 0 关注
  • 1328 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信