Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring boot run multiple instances of same profile in service

Tags:

spring-boot

In Spring boot application, how run multiple instances of same profile on same server (OS)?

like image 701
N DSI Avatar asked Mar 17 '19 05:03

N DSI


2 Answers

To run multiple instances of same profile of service

  • remove property from profile in yml (or properties) file -> server.port (this is in case of using remote configuration accessed through configuration server)
  • on running the war (or jar) set the property of port and profile in command line as follows

java -jar -Dserver.port=7012 -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar

java -jar -Dserver.port=7011 -Dspring.profiles.active=production demo-0.0.1-SNAPSHOT.jar

like image 162
Nesrin Avatar answered Oct 19 '22 00:10

Nesrin


If you want to run multiple instances of your project in sts (spring tool suite) follow below steps

  1. change server.port=0 (this makes application run on random port) in application.properties or yaml
  2. open Boot bashboard, run instance once, it will start running on random port
  3. right click that intance, click duplicate config, it will create new instance in boot dashboard
  4. run new instance that will be started on new random port

you can create as many duplicate instance you want

like image 2
Hitesh Wadhwani Avatar answered Oct 19 '22 00:10

Hitesh Wadhwani