Reputation: 53
Is it possible to start two spring boot applications in eclipse, in the same workspace in the same time? How can i set two different ports for that two spring boot applications?
Upvotes: 5
Views: 14022
Reputation: 1
Yes, you can change the port using argument -Dserver.port=XXXX to override the properties value in Run Configuration windows, each time you launch the app. Keep in mind you must change on each launch to avoid a port collision.
Upvotes: 0
Reputation: 1
Follow these steps:
Upvotes: 0
Reputation: 4156
Yes. It is possible to run two spring boot apps same time in the same workspace
in eclipse
. This is possible because each spring boot app comes with an embedded tomcat server
and we have to make sure that each of them uses a different port number respectively.
In each spring boot application, add application.properties
file in src/main/resources
folder. To override the default 8080
port, you have to use server.port property in the application.properties
file. Make sure you set different port in each of the application. For example, set server.port=8888
in one application and server.port=9999
in another application, so that app1 will run on 8888 port and app2 will run on 9999 port.
To scan for a free port (using OS natives to prevent clashes) use server.port=0.
Upvotes: 6
Reputation: 1933
You can specify the port that the embedded instance of tomcat
runs on by putting server.port=[port number here]
in your application.properties
. If you want tomcat
to run on a random port put server.port=0
in application.properties
.
I'm not sure about running two instances in the same workspace, I've never tried. But if you try to deploy and both tomcat
instances are trying to run on the same port you will get 'tomcat connector in a failed state'.
Upvotes: 1