Spring Boot Interview Questions & Answers (2025)
Spring Boot is a popular Java framework for building microservices and enterprise applications. Its auto-configuration, embedded servers, and starter dependencies make development faster and simpler. This guide covers 30 essential Spring Boot interview questions, with examples and explanations, suitable for both beginners and experienced developers.
1. What is Spring Boot?
Spring Boot is a framework built on top of Spring, designed to simplify application development. It provides auto-configuration, embedded servers, and starter dependencies.
2. Difference between Spring and Spring Boot
Feature | Spring | Spring Boot |
---|---|---|
Setup | Complex, XML-based | Auto-configured, annotation-based |
Server | Requires external server | Embedded server (Tomcat, Jetty) |
Deployment | WAR file | JAR file (standalone) |
Focus | General-purpose framework | Rapid microservice development |
3. What are Spring Boot Starters?
Starters simplify dependency management.
4. Explain Spring Boot Auto-Configuration
Spring Boot auto-configures beans based on dependencies in the classpath.
5. What is @SpringBootApplication
?
Combines:
-
@Configuration
-
@EnableAutoConfiguration
-
@ComponentScan
6. Difference between @Component
, @Service
, @Repository
, @Controller
Annotation | Usage |
---|---|
@Component | Generic bean definition |
@Service | Business/service layer |
@Repository | DAO layer, handles DB exceptions |
@Controller | Handles HTTP requests |
7. What is Spring Boot Actuator?
Provides monitoring and metrics.
Access health: http://localhost:8080/actuator/health
8. External Configuration
application.properties
or application.yml
:
9. @Value
Annotation
Injects properties:
10. @RestController
vs @Controller
Annotation | Usage |
---|---|
@Controller | Returns views (JSP, Thymeleaf) |
@RestController | Returns JSON/XML directly |
11. Exception Handling
12. Spring Boot DevTools
Provides hot reload and automatic restart.
13. Spring Boot Profiles
Environment-specific configs:
14. Spring Boot Security
15. @EnableAutoConfiguration
vs @SpringBootApplication
-
@EnableAutoConfiguration
– auto-config only -
@SpringBootApplication
– combines auto-config, component scan, configuration
16. Embedded Server
17. Spring Boot CLI
Run Groovy scripts:
18. Database Connection
19. @Entity
vs @Table
Annotation | Usage |
---|---|
@Entity | Marks class as JPA entity |
@Table | Maps entity to a table |
20. Spring Boot JPA Repositories
21. Caching
22. Scheduling
23. Testing
24. DevTools vs LiveReload
-
DevTools: auto-restart
-
LiveReload: browser refresh
25. Messaging
Supports Kafka, RabbitMQ:
26. @RequestParam
vs @PathVariable
Annotation | Usage |
---|---|
@RequestParam | Query parameters |
@PathVariable | URL path variables |
27. File Upload
28. Thymeleaf Example
29. Spring Boot Starter POMs
-
spring-boot-starter-web
-
spring-boot-starter-data-jpa
-
spring-boot-starter-security
30. Packaging
-
JAR:
java -jar target/myapp.jar
-
WAR: Deploy to external server
✍️ By Ashish | 2025-10-21T09:03:56.547Z