在将一个SpringBoot项目通过maven的命令mvn clean package -Dmaven.test.skip=true
打包成jar包后,将这个jar文件通过Xftp粘贴复制到你tomcat子目录下的webapps目录下。
在执行命令java -jar blog-0.0.1-SNAPSHOT.jar
时,出现8080端口被调用的情况,如下图:
解决方法:
Linux下
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# netstat -ano #查看所有进程
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# netstat -nlp | grep 8080 #查看占用8080端口的进程
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 32036/jsvc.exec
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# sudo lsof -i:8080
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
jsvc 32036 www 52u IPv4 450897 0t0 TCP *:webcache (LISTEN) # 查找被占用端口的PID
jsvc 32036 www 71u IPv4 1916123 0t0 TCP iZ2zeb3tq9v0wyicra3wwuZ:webcache->99-48-176-109.lightspeed.irvnca.sbcglobal.net:38786 (ESTABLISHED)
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# sudo kill -9 32036 #kill 掉这个进程
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# ls
blog-0.0.1-SNAPSHOT.jar blog.out docs examples host-manager log manager ROOT
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# nohup java -jar blog-0.0.1-SNAPSHOT.jar >> blog.out &
[1] 15242
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]# nohup: ignoring input and redirecting stderr to stdout
[root@iZ2zeb3tq9v0wyicra3wwuZ webapps]#
Windows下
步骤一:cmd输入:输入 netstat -ano
步骤二:netstat -aon|findstr "端口号"
步骤三:tasklist|findstr "查询出的 listening"
步骤四:taskkill /f /t /im 查询出占用程序名称
相关文章链接:
SpringBoot项目如何部署到公网(云服务器
Linux 如何kill杀死(关闭)某个被占用的端口
怎么修改tomcat端口,当tomcat端口被占用怎么查看占用程序