Java 尝试从 Spring Tool Suite IDE 重新部署项目时,8080 端口已经出现问题
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/40118878/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
8080 port already taken issue when trying to redeploy project from Spring Tool Suite IDE
提问by milan.latinovic
I have strange thing when I try to modify Spring project inside my Spring Tool Suite. On the first load (deploy) everything is fine, application compiles and runs on localhost:8080
当我尝试在我的 Spring Tool Suite 中修改 Spring 项目时,我遇到了奇怪的事情。在第一次加载(部署)时一切正常,应用程序编译并在 localhost:8080 上运行
When I change something inside code and try to redeploy it (Run it again - Run As Spring Boot App) I get error message
当我更改代码中的某些内容并尝试重新部署它时(再次运行 - 作为 Spring Boot 应用程序运行),我收到错误消息
*************************** APPLICATION FAILED TO START
Description:
The Tomcat connector configured to listen on port 8080 failed to start. The port may already be in use or the connector may be misconfigured.
Action:
Verify the connector's configuration, identify and stop any process that's listening on port 8080, or configure this application to listen on another port.
2016-10-19 00:01:22.615 INFO 10988 --- [ main] ationConfigEmbeddedWebApplicationContext : Closing org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3023df74: startup date [Wed Oct 19 00:01:19 CEST 2016]; root of context hierarchy 2016-10-19 00:01:22.616 INFO 10988 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Unregistering JMX-exposed beans on shutdown
**************************** 应用程序无法启动
描述:
配置为侦听端口 8080 的 Tomcat 连接器无法启动。端口可能已在使用中,或者连接器可能配置错误。
行动:
验证连接器的配置,识别并停止侦听端口 8080 的任何进程,或将此应用程序配置为侦听另一个端口。
2016 年 10 月 19 日 00:01:22.615 信息 10988 --- [主要] ationConfigEmbeddedWebApplicationContext:关闭 org.springframework.boot.context.embedded.AnnotationConfigEmbeddedWebApplicationContext@3023df74:启动日期 [星期三:10 年 10 月 19 日:美国东部标准时间 10 月 19 日:C10 上下文层次结构的根 2016-10-19 00:01:22.616 INFO 10988 --- [main] osjeaAnnotationMBeanExporter:在关闭时取消注册暴露于 JMX 的 bean
If I shutdown process on that port manually everything works fine again, but this can't be right way of redeploying Spring app. Am I doing something wrong here?
如果我手动关闭该端口上的进程,一切正常,但这不是重新部署 Spring 应用程序的正确方法。我在这里做错了吗?
I'm using :: Spring Boot :: (v1.4.1.RELEASE)
我正在使用:: Spring Boot :: (v1.4.1.RELEASE)
P.S. I'm aware that I can setup some kind of hot-swap mechanism to have automatic reload of page after I change code, but for now I would like to resolve this issue first.
PS 我知道我可以设置某种热插拔机制来在更改代码后自动重新加载页面,但现在我想先解决这个问题。
Thanks for any kind of help or info.
感谢您提供任何帮助或信息。
回答by so-random-dude
Am I doing something wrong here?
我在这里做错了吗?
Yes, you are. One servlet container is already running on port 8080 and you are trying to run another one on port 8080 again.
是的,你是。一个 servlet 容器已在端口 8080 上运行,而您正尝试再次在端口 8080 上运行另一个容器。
Either restart the server (If there is button for that in STS) or stop and start it
重新启动服务器(如果 STS 中有该按钮)或停止并启动它
回答by Achille_vanhoutte
This is a typical startup failure due to the embedded servlet container's port being in use.
这是典型的启动失败,原因是嵌入式 servlet 容器的端口正在使用中。
Your embedded tomcat container failed to start because Port 8080 was already in use.
您的嵌入式 tomcat 容器无法启动,因为端口 8080 已被使用。
Just Identify and stop the process that's listening on port 8080 or configure (in you application.propertiesfile )this application to listen on another port.
只需识别并停止侦听端口 8080 的进程或配置(在您的application.properties文件中)此应用程序以侦听另一个端口。
回答by Lukas Lechner
回答by Registered User
In my case, the error occurred as the application was unable to access the keystore for ssl.
就我而言,错误发生是因为应用程序无法访问 ssl 的密钥库。
Starting the application as root user fixed the issue.
以 root 用户身份启动应用程序解决了这个问题。
回答by besartm
Just click red button to stop all services on eclipse than re- run application as Spring Boot Application - This worked for me.
只需单击红色按钮即可停止 eclipse 上的所有服务,然后将应用程序重新运行为 Spring Boot 应用程序 - 这对我有用。
回答by rdj7
It sometimes happen even when we stop running processes in IDE with help of Red button, we continue to get same error.
即使我们在 IDE 中借助红色按钮停止运行进程,有时也会发生这种情况,我们继续遇到相同的错误。
It was resolved with following steps,
已通过以下步骤解决,
Check what processes are running at available ports
netstat -ao |find /i "listening"
We get following
TCP 0.0.0.0:7981 machinename:0 LISTENING 2428 TCP 0.0.0.0:7982 machinename:0 LISTENING 2428 TCP 0.0.0.0:8080 machinename:0 LISTENING 12704 TCP 0.0.0.0:8500 machinename:0 LISTENING 2428
i.e. Port Numbers and what Process Idthey are listening to
Stop process running at your port number(In this case it is 8080 & Process Id is 12704)
Taskkill /F /IM 12704
(Note: Mention correct Process Id)
检查哪些进程在可用端口上运行
netstat -ao |find /i "listening"
我们得到以下
TCP 0.0.0.0:7981 machinename:0 LISTENING 2428 TCP 0.0.0.0:7982 machinename:0 LISTENING 2428 TCP 0.0.0.0:8080 machinename:0 LISTENING 12704 TCP 0.0.0.0:8500 machinename:0 LISTENING 2428
即端口号和 他们正在侦听的进程 ID
停止在您的端口号上运行的进程(在本例中为 8080,进程 ID 为 12704)
Taskkill /F /IM 12704
(注意:提及正确的进程 ID)
For more information follow these links Link1and Link2.
My Issue was resolved with this, Hope this helps !
我的问题已解决,希望对您有所帮助!
回答by Hari Tummala
If you got any error on your console by saying, “Embedded servlet container failed to start. Port 8080 was already in use.” Then go to application.properties file and add this property “server.port = 8090”.
如果您在控制台上遇到任何错误,提示“嵌入式 servlet 容器无法启动。端口 8080 已被使用。” 然后转到 application.properties 文件并添加此属性“server.port = 8090”。
Actually the default port for spring boot is 8080, if you have something else on that port, the above error will occur. So we are asking spring boot to run on other port by adding “server.port = 8090” in application.properties file.
实际上spring boot的默认端口是8080,如果你在那个端口上有别的东西,就会出现上面的错误。因此,我们通过在 application.properties 文件中添加“server.port = 8090”来要求 Spring Boot 在其他端口上运行。
回答by samivic
Open "localhost:8080" on your browser and see what is running on this port.
I did it and I just found Oracle 10g XE running on background, so I went to start->Services and stopped all oracle services. Then I redo mvnw spring-boot:run
on IntelliJ and it runs like magic.
在浏览器上打开“localhost:8080”,看看这个端口上正在运行什么。我做到了,我发现 Oracle 10g XE 在后台运行,所以我去开始->服务并停止所有 oracle 服务。然后我mvnw spring-boot:run
在 IntelliJ 上重做,它像魔术一样运行。
回答by Shubham Chopra
There are two ways to resolve this issue.Try option 1 first, if it doesn't work try option 2, and your problem is solved.
有两种方法可以解决此问题。首先尝试选项 1,如果它不起作用,请尝试选项 2,您的问题就解决了。
1) On the top right corner of your console, there is a red button, to stop the spring boot application which is already running on this port just click on the red button to terminate.
1) 在控制台的右上角,有一个红色按钮,要停止已经在此端口上运行的 Spring Boot 应用程序,只需单击红色按钮即可终止。
2) If the red button is not activated you need to right click on the console and select terminate/disconnect all. Hope this helps.
2) 如果红色按钮未激活,您需要右键单击控制台并选择终止/全部断开连接。希望这可以帮助。
Bonus tip:- If you want to run your server on a different port of your choice, create a file named application.properties in resource folder of your maven project and write server.port=3000 to run your application on port 3000
额外提示:- 如果您想在您选择的不同端口上运行您的服务器,请在您的 maven 项目的资源文件夹中创建一个名为 application.properties 的文件,并写入 server.port=3000 以在端口 3000 上运行您的应用程序
回答by singh30
On Linux Machine, save the bash script and execute it. If you want to free port 8080, Input 8080 when prompted
在 Linux 机器上,保存 bash 脚本并执行它。如果要释放8080端口,提示时输入8080
echo "Enter port number to be closed :: "
read port
sudo kill $(sudo lsof -t -i:$port)