Spring Boot Interview Questions And Answers.

Gain Java Knowledge
6 min readMay 18, 2022

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.

@SpringBootApplication

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.

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.
vii. Actuators

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.

--

--

Gain Java Knowledge

The Java programming language is one of the most popular languages today. Stay up to date with news, certifications, free learning resources and much more.