I'm developing a REST API using Spring Framework.
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.
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.
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?
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.
server.port=0
which will find a random open port to use. Although I suggest you find out a way to stop your application properly. – codingbash