Spring Boot is the dominant Java framework for REST APIs and microservices. It provides auto-configuration, embedded Tomcat, dependency injection, and a vast ecosystem (Data, Security, Cloud).
Conceptual REST controller
@RestController
class HelloController {
@GetMapping("/hello")
String hello() { return "Hello"; }
}
Spring creates beans, wires dependencies, and maps HTTP routes—no manual new for services in application code.
Why teams pick it
- Convention over configuration—fast MVP to production
- Integration with JDBC, JPA, Kafka, Redis via starters
- Large hiring market and documentation
Playground note
Running Spring needs multi-file projects and ports—this lesson prints mock endpoint responses. Follow a dedicated Spring track locally with spring init on start.spring.io.
Important interview questions and answers
- Q: What is dependency injection?
A: Objects receive collaborators from the container instead of constructing them—easier testing and swapping implementations. - Q: @Component vs @Service?
A: @Service is a stereotype of @Component for domain services—same registration, semantic clarity.
Self-check
- What annotation marks a REST JSON endpoint class?
- Why use Spring Boot over plain servlets for new APIs?
Interview prep
- What is dependency injection?
Spring creates and wires beans (services, repositories) so classes receive dependencies instead of constructing them—easier testing and swapping implementations.