What are the most common Spring Boot annotations?
The most common annotations are SpringBootApplication to start the app, RestController and RequestMapping to build web endpoints, Autowired for dependency injection, and the stereotype annotations Component, Service, and Repository to define beans. Knowing what each does and roughly when to use it covers most day to day Spring Boot code.
- SpringBootApplication combines configuration, auto configuration, and component scanning.
- RestController and RequestMapping define web endpoints.
- Autowired injects dependencies, and stereotypes like Service register beans.
The ones you will use most
- SpringBootApplication: marks the main class and enables auto configuration.
- RestController: marks a class that handles web requests and returns data.
- RequestMapping, GetMapping, PostMapping: map URLs to methods.
- Autowired: injects a dependency.
- Component, Service, Repository: define beans by layer.
@RestController
class HelloController {
@GetMapping("/hello")
String hello() { return "hi"; }
}
Do not just list annotations, group them by purpose: startup, web, injection, and beans. Organising your answer this way makes it clear you understand the roles rather than memorising a list.
Frequently asked questions
What does SpringBootApplication combine?
It bundles Configuration, EnableAutoConfiguration, and ComponentScan into one convenient annotation placed on the main class.
What is the difference between RequestMapping and GetMapping?
RequestMapping can map any HTTP method, while GetMapping is a shortcut specifically for GET requests. Similar shortcuts exist for POST, PUT, and DELETE.
Common follow up questions
Related interview questions
Want the full Spring Boot guide?
Read every Spring Boot concept with notes, diagrams, and code in one place. Track your progress as you go.
Open the Spring Boot guide All Spring Boot questions