DEV Community

Cover image for Best Ways to Run Spring Boot app Via Console or Terminal
Sanjay
Sanjay

Posted on • Updated on

Best Ways to Run Spring Boot app Via Console or Terminal

1. Using Basic Jar Command

java -jar webapp-1.0.0.SNAPSHOT.jar 
Enter fullscreen mode Exit fullscreen mode

2.Using Spring Active Profiles in Spring Boot

java -jar -Dspring.profiles.active=dev webapp-1.0.0.SNAPSHOT.jar 
Enter fullscreen mode Exit fullscreen mode

A Second Variation of this

java -jar -Dspring.profiles.active=dev -Dserver.port=9090 webapp-1.0.0.SNAPSHOT.jar  
Enter fullscreen mode Exit fullscreen mode

If you are running on any centos or linux box in production have a look at running using nohup command .

3. Run When You do not get the Reason why something bad Happened eg - like Spring Bean Creation Errors

mvn spring-boot:run
Enter fullscreen mode Exit fullscreen mode

4. Running Using Jar Launcher and Extracting Jar .

My personal favorite way of deploying spring boot applications .

Step 1 :-

Jar -xvf webapp-1.0.0.SNAPSHOT.jar
Enter fullscreen mode Exit fullscreen mode

Step 2 :-

java -Dspring.profiles.active=dev -Xdebug -Xnoagent -Djava.compiler=NONE org.springframework.boot.loader.JarLauncher 
Enter fullscreen mode Exit fullscreen mode

Note:- You can provide a hot fix in prod too using this . Give me a Like if you didn't Know this Hot Fix tricks.

Have a look in depth here .

Top comments (0)