Member-only story
Spring Boot Interview Questions And Answers.
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.
Spring Boot @SpringBootApplication annotation is used to mark a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning.
@Configuration
This annotation marks a class as a Configuration class for Java-based configuration.
@ComponentScan
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.
@EnableAutoConfiguration
This annotation enables the magical auto-configuration feature of Spring Boot, which can automatically configure a lot of stuff for you.