Java Spring Boot Interview Questions and Answers
1. What is Spring Boot?
Spring Boot is an open-source Java-based framework used to create stand-alone, production-grade
Spring-based applications. It simplifies the setup and development of new Spring applications with
features like auto-configuration and embedded servers.
2. What are the main features of Spring Boot?
- Auto Configuration
- Embedded Server support (Tomcat, Jetty)
- Starter Dependencies
- Spring Boot CLI
- Production-ready features (like metrics and health checks)
3. What is the difference between Spring and Spring Boot?
Spring is a comprehensive framework for Java applications, while Spring Boot is a tool built on top
of Spring to simplify application development by eliminating boilerplate configuration.
4. What is Spring Boot Starter?
A Spring Boot Starter is a dependency descriptor that bundles commonly used dependencies into a
single package for easy inclusion in your project.
5. What is Spring Initializr?
Spring Initializr is a web-based tool to bootstrap a Spring Boot application by generating a Maven or
Gradle project with the necessary dependencies and configurations.
6. How does Spring Boot handle application configuration?
Spring Boot supports external configuration using properties or YAML files ([Link] or
[Link]), environment variables, and command-line arguments.
7. What is the purpose of @SpringBootApplication annotation?
It is a convenience annotation that combines @Configuration, @EnableAutoConfiguration, and
@ComponentScan annotations with their default attributes.
8. What is Spring Boot Actuator?
Spring Boot Actuator provides production-ready features to help you monitor and manage your
application, such as health checks, metrics, info, dump, etc.
9. How do you create a REST API using Spring Boot?
By using @RestController and mapping HTTP methods (GET, POST, PUT, DELETE) with
@RequestMapping or its variants like @GetMapping, @PostMapping, etc.
10. How do you handle exceptions in Spring Boot?
By using @ControllerAdvice and @ExceptionHandler to create a global exception handler class that
intercepts and processes application exceptions.