Java eclipse中Spring Boot应用,配置监听XXXX端口的Tomcat连接器启动失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/43026358/
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
Spring Boot application in eclipse, the Tomcat connector configured to listen on port XXXX failed to start
提问by Sandoval0992
I'm developing a REST API using Spring Framework.
我正在使用 Spring Framework 开发 REST API。
First I wasn't able to run my application because of the same problem. The port 8080 on my computer is busy.
Then I found out that one alternative to solve this problem is creating an application.properties
file under src/main/resources
folder.
That's what I made, and set up the server to listen on port 8090. This worked but only for the first time, now I'm getting the same exception whenever I try to run the application for the second time.
首先,由于同样的问题,我无法运行我的应用程序。我电脑的 8080 端口很忙。然后我发现解决这个问题的一种方法是application.properties
在src/main/resources
文件夹下创建一个文件。这就是我所做的,并将服务器设置为侦听端口 8090。这只是第一次有效,现在每当我第二次尝试运行应用程序时,都会遇到相同的异常。
Description:
The Tomcat connector configured to listen on port 8090 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 8090, or configure this application to listen on another port.
As far as I know, this framework makes use of an embedded instance of apache tomcat to deploy every application.
据我所知,这个框架利用 apache tomcat 的嵌入式实例来部署每个应用程序。
My guess is, the server is not getting restarted the second time I try to run the app, that's why the output says " The port may already be in use or the connector may be misconfigured"
我的猜测是,服务器在我第二次尝试运行应用程序时没有重新启动,这就是为什么输出显示“端口可能已被使用或连接器可能配置错误”
So, a more specific question would be, how can I manage the embedded instance of apache tomcat either manually or programmatically?
那么,一个更具体的问题是,如何手动或以编程方式管理 apache tomcat 的嵌入式实例?
I've also modified the port in the application.properties
file twice. It works fine, but again, only for the first time. As you can imagine I cannot do the same each time the app is going to be executed.
我还修改了application.properties
文件中的端口两次。它工作正常,但同样,只是第一次。正如您可以想象的那样,每次执行应用程序时我都不能做同样的事情。
采纳答案by Edge
On the console, looking at the topmost right side of the dialog you should see a red button kinda like a buzzer. To stop the spring boot application properly you just ran, go ahead and hit this particular "red" button and your problem is solved. Hope this helps!
在控制台上,查看对话框的最右上角,您应该会看到一个有点像蜂鸣器的红色按钮。要正确停止刚刚运行的 spring boot 应用程序,请继续点击这个特定的“红色”按钮,您的问题就解决了。希望这可以帮助!
回答by Opster Elasticsearch Ninja
Its because you are not stopping your application, before starting it another time, hence it says port is already in use.
这是因为您没有停止应用程序,然后再启动它,因此它说端口已在使用中。
You should always stop application before starting it again, otherwise you will run into the port conflict issues.
在再次启动之前,您应该始终停止应用程序,否则您将遇到端口冲突问题。
Depending on your platform, if your running it on windows you can use netstat -anp | find "port number"
or if you are running it on linux, you can use netstat -ntpl | grep "port number"
or if mac , use lsof -n -iTCP:"port number"
.
根据您的平台,如果您在 windows 上运行它可以使用,netstat -anp | find "port number"
或者如果您在 linux 上运行它,您可以使用netstat -ntpl | grep "port number"
或者如果 mac 使用lsof -n -iTCP:"port number"
.
回答by DvixExtract
Another easy way of solving this error is right clicking in the console and click on Terminate/Disconnect All. Afterwards run the application it should work fine.
解决此错误的另一种简单方法是右键单击控制台,然后单击“终止/断开所有连接”。之后运行应用程序它应该可以正常工作。
回答by Gene
Find the process and terminate it.
On Windows do a Control+Alt+Delete and then find the "Java(TM) Platform SE Binary" process under the Processes Tab. For example:
找到进程并终止它。在 Windows 上执行 Control+Alt+Delete,然后在 Processes 选项卡下找到“Java(TM) Platform SE Binary”进程。例如:
On Ubuntu, you can use "ps aux | grep java" to find the process and "kill -9 PID_NUMBER" to kill the process.
在 Ubuntu 上,您可以使用“ps aux | grep java”来查找进程并使用“kill -9 PID_NUMBER”来终止进程。
OR
或者
If you're using a Spring boot application, go to application.properties and add this:
如果您使用的是 Spring Boot 应用程序,请转到 application.properties 并添加以下内容:
server.port = 8081
回答by alok
- check the port which is busy: netstat -ntlp
- kill that port : kill -9 xxxx
- 检查繁忙的端口:netstat -ntlp
- 杀死那个端口:kill -9 xxxx
回答by sy456
Find the process ID (PID) for the port (e.g.: 8080)
On Windows:
netstat -ao | find "8080"
Other Platforms other than windows :
lsof -i:8080
Kill the process ID you found (e.g.: 20712)
On Windows:
Taskkill /PID 20712 /F
Other Platforms other than windows :
kill -9 20712 or kill 20712
查找端口的进程 ID (PID)(例如:8080)
在 Windows 上:
netstat -ao | find "8080"
windows以外的其他平台:
lsof -i:8080
杀死您找到的进程 ID(例如:20712)
在 Windows 上:
Taskkill /PID 20712 /F
windows以外的其他平台:
kill -9 20712 or kill 20712
回答by Ashish Patel
There are two options to handle / avoid this situation.
有两种选择可以处理/避免这种情况。
Before re-running the application just terminate the previous connection.
Open the console --> right click --> terminate all.
If you forgot to perform action mention on step 1 then
- Figure out the the port used by your application, you could see it the stack trace in console window
- Figure out the process id associated to port by executing netstat -aoncommand in cmd
- Kill that process and re-run the application.
在重新运行应用程序之前,只需终止之前的连接。
Open the console --> right click --> terminate all.
如果您忘记在步骤 1 中执行提及的操作,则
- 找出您的应用程序使用的端口,您可以在控制台窗口中看到堆栈跟踪
- 通过在cmd中执行netstat -aon命令找出与端口关联的进程ID
- 终止该进程并重新运行应用程序。
回答by Devender Goyal
On Windows:
在 Windows 上:
To get started, open the command prompt by clicking on Start and then typing cmd. In the command window, go ahead and type in the following command:
首先,通过单击“开始”然后键入 cmd 打开命令提示符。在命令窗口中,继续并输入以下命令:
netstat -a -n -o
netstat -a -n -o
In the command above, the -o parameter is what will add the PID to the end of the table. Press enter and you should see something like this:
在上面的命令中,-o 参数用于将 PID 添加到表的末尾。按 Enter 键,您应该会看到如下内容:
Now to see the name of the process that is using that port, go to Task Manager by pressing CTRL + SHIFT + ESC and then click on the Process tab. In Windows 10, you should click on the Details tab.
现在要查看使用该端口的进程的名称,请按 CTRL + SHIFT + ESC 转到任务管理器,然后单击进程选项卡。在 Windows 10 中,您应该单击“详细信息”选项卡。
By default, the task manager does not display the process ID, so you have to click on View and then Select Columns.
默认情况下,任务管理器不显示进程 ID,因此您必须单击查看,然后单击选择列。
You might also need to look into services running in background. To do that right-click and select open services as shown below:
您可能还需要查看在后台运行的服务。为此,请右键单击并选择打开的服务,如下所示:
Hope it helps :)
希望能帮助到你 :)
回答by Filip
In case your app is run on httpS, make sure you put right values under the following properties:
如果您的应用程序在 httpS 上运行,请确保在以下属性下放置正确的值:
server.ssl.key-store-password=
server.ssl.key-alias=
I got the same error when I put the wrong values here
当我在这里输入错误的值时,我遇到了同样的错误