springboot-springboot interview questions and answers series 2
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:
or by using gradle command:
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:
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:
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:
or by this command:
To be continued…