Category: java
spring boot interview questions
Published on 15 Apr 2026
Explanation
What is Spring Boot and why is
it used?
Code:
Spring Boot is a framework built on top
of Spring that simplifies application
development by providing
auto-configuration, embedded servers,
and production-ready features.
Example:
@SpringBootApplication
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.
class, args);
}
}
Explanation
What is @SpringBootApplication annotation?
Code:
@SpringBootApplication is a combination of: 1. @Configuration 2. @EnableAutoConfiguration 3. @ComponentScan It enables auto configuration and component scanning.
Explanation
What is auto-configuration in Spring Boot?
Code:
Auto-configuration automatically configures beans based on dependencies available in the classpath. Example: If spring-boot-starter-web is added, DispatcherServlet is configured automatically.
Explanation
What are Spring Boot Starters?
Code:
Starter dependencies simplify dependency management. Example: <dependency> <groupId>org.springframework.boot </groupId> <artifactId>spring-boot-starter-web </artifactId> </dependency>
Explanation
What is the difference between
@Component, @Service,
@Repository, and @Controller?
Code:
@Component β Generic bean @Service β Business logic layer @Repository β Persistence layer @Controller β Web MVC controller
Explanation
What is @RestController?
Code:
@RestController combines
@Controller and @ResponseBody.
Example:
@RestController
public class HelloController {
@GetMapping("/hello")
public String hello() {
return "Hello Spring Boot";
}
}