Spring Boot Interview Questions

1) What is Spring Boot?

Spring Boot is a Spring module which provides RAD (Rapid Application Development) feature to Spring framework.

It is used to create stand alone spring based application that you can "just run" because it needs very little spring configuration.

2) Why we need Spring Boot?

Spring Framework aims to simplify Java Applications Development.

Spring Boot Framework aims to simplify Spring Development.

3) What are the features of Spring Boot?

Web Development
SpringApplication
Application events and listeners
Admin features

1. Starter dependency

This feature aggregates common dependencies together. 
For example, if you want to develop Spring MVC based RESTful services then instead of including Spring MVC JAR and 
Jackson JAR file into classpath you can just specify spring-boot-web-starter and it will automatically download both 
those JAR files. Spring Boot comes with many such starter dependencies to improve productivity.

2. Auto-Configuration

This is another awesome features of Spring Boot which can configure many things for you. 
For example, If you are developing Spring web application and Thymeleaf.jar is present on the classpath then it can 
automatically configure Thymeleaf template resolver, view resolver, and other settings.

3. Spring Initializer

A web application which can create initial project structure for you. This simplifies initial project setup part.

4. Spring Actuator

This feature provides a lot of insights of a running Spring boot application.
 For example, you can use Actuator to find out which beans are created in Spring's application context 
and which request path are mapped to controllers.

5. Spring CLI

This is another awesome feature of Spring Boot which really takes Spring development into next level.
 It allows you to use Groovy for writing Spring boot application which means a lot more concise code.

Spring Vs Spring Boot?

Spring is a web application framework based on Java. It provides tools and libraries to create a complete cutomized web application.

Wheras Spring Boot is a spring module which is used to create spring application project that can just run.

Spring Boot Components:

Spring Boot Starter
Spring Boot AutoConfigurator
Spring Boot Actuator
Spring Boot CLI
Spring Boot Initilizr

What is Spring Boot Starter?

Spring Boot Starters are just JAR Files. They are used by Spring Boot Framework to provide “Auto-Dependency Resolution”.

What is Spring Boot AutoConfigurator?

Spring Boot AutoConfigurator is used by Spring Boot Framework to provide “Auto-Configuration”.

What is Spring Boot Actuator?

Spring Boot Actuator is used by Spring Boot Framework to provide “Management EndPoints” to see Application Internals, 
Metrics etc.

What is Spring Boot CLI?

In simple words, Spring Boot CLI is Auto Dependency Resolution, Auto-Configuration, Management EndPoints, Embedded HTTP Servers(Jetty, Tomcat etc.) and (Groovy, Auto-Imports)

13. What are some common Spring Boot annotations?

Some of the most common Spring Boot annotations are @EnableAutoConfiguration, @SpringBootApplication, @SpringBootConfiguration, and @SpringBootTest.

The @EnableAutoConfiguration is used to enable auto-configuration on Spring Boot application, while @SpringBootApplication is used on the Main class to allow it to run a JAR file. @SpringBootTest is used to run unit test on Spring Boot environment.


14. Can you name some common Spring Boot Starter POMs?

Some of the most common Spring Boot Start dependencies or POMs are spring-boot-starter, spring-boot-starter-web, spring-boot-starter-test. You can use spring-boot-starter-web to enable Spring MVC in Spring Boot application.


15. Can you control logging with Spring Boot? How?

Yes, we can control logging with Spring Boot by specifying log levels on application.properties file. Spring Boot loads this file when it exists in the classpath and it can be used to configure both Spring Boot and application code.

Spring Boot uses Commons Logging for all internal logging and you can change log levels by adding following lines in the application.properties file:

logging.level.org.springframework=DEBUG
logging.level.com.demo=INFO