1. The purpose of this post

From this post on, I would show some questions and answers of springboot interviews.

2. Environments

  • springboot 1.x and 2.x

3. Springboot Interview Questions and Answers Series 2

3.1 What are the ways to run Spring Boot Apps?

There are three ways to start spring boot apps

3.1 Package as WAR and start in web container(tomcat)

Springboot apps can be packaged as WAR files and deployed into web contains like apache tomcat. You can follow this article Complete guide to package springboot apps as WAR and deploy to tomcat to package the spring apps as WAR files and deploy to tomcat.

3.2 Start by using maven or gradle commands

Secondly , you can start springboot apps by using this maven command:

mvn springboot:run

or by using gradle command:

gradle bootRun

3.3 Start by using java commands

Normally, springboot apps can be packaged as jar files, you must add these configurations to your POM:

Set the start class of your app:


add this build plugin to get a standalone executable jar:


Then when you package the app using:

mvn clean package

You would get an executable jar file as this: springboot2-jdbctemplate-exec.jar

Unzip the jar ,and view the META-INF/MANIFEST.MF , you would get this:

Manifest-Version: 1.0
Archiver-Version: Plexus Archiver
Built-By: bswen
Start-Class: com.test.MainApp
Spring-Boot-Classes: BOOT-INF/classes/
Spring-Boot-Lib: BOOT-INF/lib/
Spring-Boot-Version: 2.2.0.M3
Created-By: Apache Maven 3.3.9
Build-Jdk: 1.8.0_121
Main-Class: org.springframework.boot.loader.JarLauncher

You can see that the Main class is replace by springboot JarLauncher, and the start-class is the class you set in your POM.

then you can execute it by using this command:

java -jar springboot2-jdbctemplate-exec.jar

or by this command:

java -cp springboot2-jdbctemplate-exec.jar -Dloader.main=com.test.MainApp org.springframework.boot.loader.JarLauncher

To be continued…