Tuesday, June 3, 2025

Run Same SpringBoot application with custom port : use -Dserver.port option

 You can run a spring boot application in various ways.

Let's assume that you are running the jar file in a command line. In application properties server.port=8001 and we are starting application with custom port=8002

Command will be 

java -jar -Dserver.port={custom port number} {jar name}

java -jar -Dserver.port=8002 greet-service-with-eureka-0.0.1-SNAPSHOT.jar


Note: we are putting -D option just before the application property name


In Eureka Server , you can see one is running in 8001 and other in 8002 port.




No comments:

Post a Comment