In this tutorial, I have discussed the spring boot top questions and answers with proper explanation and examples.
Q1. What does the @SpringBootApplication annotation do internally?
Ans : The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScan with their default attributes. Spring Boot enables the developer to use a single annotation instead of using multiple. But as we know, Spring provided loosely coupled features that we can use for each annotation as per our project needs.
This annotation marks a class as a Configuration class for Java-based configuration.
This annotation enables component-scanning so that the web controller classes and other components you create will be automatically discovered and registered as beans in Spring’s Application Context. All the @Controller classes you write are discovered by this annotation.
This annotation enables the magical auto-configuration feature of Spring Boot, which can automatically configure a lot of stuff for you.
Q 2. Which feature Spring Boot offers but Spring doesn’t ?
Ans : Below are some key points which spring boot offers but spring doesn’t:
i. Starter POM.
ii. Version Management.
iii. Auto Configuration.
iv. Component Scanning.
v. Embedded server.
vi. InMemory DB.
Q 3. How does Spring Boot works?
Ans : Spring Boot automatically configures your application based on the dependencies you have added to the project by using annotation. The entry point of the spring boot application is the class that contains @SpringBootApplication annotation and the main method.