Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Start two springboot apps in eclipse

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?

like image 817
ratkov_a Avatar asked Jan 27 '16 11:01

ratkov_a


People also ask

How do I connect one spring boot application to another spring boot application?

Spring boot has inbuilt tomcat, simply right click on the import project and select run as --> java application Your application will start on port 8080. Now, you can create one more similar application and can run the application on port 8081 by adding a property server. port=8081 in your 2nd application.

How do I start spring boot in Eclipse?

In Eclipse/STS, start with File -> New -> Spring Starter Project as shown below. In the next screen, you can choose the following for your project. Make sure you choose Maven as Type. In the next screen, you can choose the dependencies that you would want to add to your Spring Boot project.


1 Answers

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.

like image 181
Omkar Puttagunta Avatar answered Sep 22 '22 04:09

Omkar Puttagunta