Module 17: Complete Reference of Spring Boot Annotations
Module Objectives
This module is a comprehensive reference of all the Spring Boot annotations you will encounter in development. It covers:
- Core Spring annotations (IoC, DI, configuration)
- Web and REST annotations
- Persistence annotations (JPA/Hibernate)
- Security, testing, and advanced annotations
Module Outline
| # | Chapter | Content |
|---|---|---|
| 1 | Core Spring Annotations | @Component, @Service, @Repository, @Configuration, @Bean, @Autowired, @Value, @Profile, @Scope, @Conditional... |
| 2 | Web and REST Annotations | @RestController, @RequestMapping, @GetMapping, @PostMapping, @RequestBody, @PathVariable, @ResponseStatus, @CrossOrigin... |
| 3 | Data and JPA Annotations | @Entity, @Table, @Id, @GeneratedValue, @Column, @OneToMany, @ManyToOne, @Query, @Transactional, @Modifying... |
| 4 | Security, Test, and Advanced Annotations | @EnableWebSecurity, @PreAuthorize, @SpringBootTest, @MockBean, @Scheduled, @Async, @EnableCaching, @Validated... |
| 5 | Complete A-Z Dictionary | 120+ annotations sorted alphabetically with short descriptions — quick reference |
How to Use This Module
Reference Guide
This module is designed as an annotations dictionary. You don't need to read it from start to finish. Use it as a reference when you encounter an unknown annotation or when you're looking for the right annotation for your need.
Journey of an HTTP Request in Spring Boot
Overview: from Client to Database
Detailed Flow with Annotations
Layered Architecture and Their Annotations
Concrete Example: GET /api/users/1
Concrete Example: POST /api/products (creation)
Color Legend
| Color | Layer | Main Annotations |
|---|---|---|
| 🔵 Blue | Client | HTTP Request / JSON Response |
| 🔴 Red | Security | @EnableWebSecurity, JwtFilter, @PreAuthorize |
| 🟢 Green | Controller | @RestController, @GetMapping, @PostMapping |
| 🟡 Yellow | Service | @Service, @Transactional, business logic |
| 🟠 Orange | Repository | @Repository, JpaRepository, @Query |
| 🟣 Purple | Database | @Entity, @Table, @Id, @Column |
Annotations by Category
Spring Boot Annotations
├── Core Spring
│ ├── Stereotypes: @Component, @Service, @Repository, @Controller
│ ├── Configuration: @Configuration, @Bean, @PropertySource
│ ├── Injection: @Autowired, @Qualifier, @Value, @Inject
│ └── Lifecycle: @PostConstruct, @PreDestroy, @Scope
│
├── Web / REST
│ ├── Controllers: @RestController, @Controller
│ ├── Mapping: @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PatchMapping
│ ├── Parameters: @RequestParam, @PathVariable, @RequestBody, @RequestHeader
│ └── Responses: @ResponseBody, @ResponseStatus, @ExceptionHandler
│
├── Data / JPA
│ ├── Entities: @Entity, @Table, @Id, @GeneratedValue, @Column
│ ├── Relationships: @OneToOne, @OneToMany, @ManyToOne, @ManyToMany
│ ├── Queries: @Query, @NamedQuery, @Modifying
│ └── Transactions: @Transactional, @EnableJpaRepositories
│
├── Security
│ ├── Config: @EnableWebSecurity, @EnableMethodSecurity
│ └── Authorization: @PreAuthorize, @PostAuthorize, @Secured
│
├── Test
│ ├── Boot: @SpringBootTest, @WebMvcTest, @DataJpaTest
│ ├── Mock: @MockBean, @SpyBean
│ └── Config: @TestConfiguration, @ActiveProfiles
│
└── Advanced
├── Async: @Async, @Scheduled, @EnableScheduling
├── Cache: @Cacheable, @CacheEvict, @EnableCaching
├── Validation: @Valid, @NotNull, @Size, @Email
└── Boot: @SpringBootApplication, @ConditionalOnProperty
Next Step
➡️ Chapter 1: Core Spring Annotations