🧩 Blueprint β€” Spring Annotations Cheatsheets

Goal: Create a modular, future-proof structure for documenting Spring annotations, grouped by capability (not by module).
This ensures scalability as the ecosystem grows (Boot, WebFlux, Security, Kafka, etc.) without fragmenting related topics.


πŸ“ Folder Layout

cheatsheets/
└─ frameworks/
└─ spring/
└─ annotations/
β”œβ”€ index.md                       # master overview & quick links
β”œβ”€ core-di/
β”‚  β”œβ”€ stereotypes.md              # @Component, @Service, @Repository, @Controller
β”‚  β”œβ”€ configuration-beans.md      # @Configuration, @Bean, @Import, @Lazy, @Scope
β”‚  β”œβ”€ wiring-and-profiles.md      # @Autowired, @Qualifier, @Primary, @Value, @Profile
β”‚  β”œβ”€ conditions.md               # @Conditional*, meta-annotations
β”‚  └─ lifecycle-events.md         # @PostConstruct, @PreDestroy, @EventListener
β”œβ”€ mvc-rest/
β”‚  β”œβ”€ controller-basics.md        # @Controller, @RestController, @ControllerAdvice
β”‚  β”œβ”€ mapping.md                  # @RequestMapping, @Get/Post/Put/Delete/PatchMapping
β”‚  β”œβ”€ params-and-bodies.md        # @PathVariable, @RequestParam, @RequestBody, @ResponseBody
β”‚  β”œβ”€ responses-and-errors.md     # @ResponseStatus, @ExceptionHandler, @ResponseEntity*
β”‚  └─ cors-and-versioning.md      # @CrossOrigin, versioning patterns
β”œβ”€ webflux/
β”‚  β”œβ”€ enable-and-config.md        # @EnableWebFlux, functional routing notes
β”‚  └─ controller-notes.md         # shared controller annotations + reactive caveats
β”œβ”€ validation/
β”‚  β”œβ”€ method-level.md             # @Validated, @Valid
β”‚  └─ bean-constraints.md         # Jakarta validation annotations
β”œβ”€ data/
β”‚  β”œβ”€ repositories.md             # @Repository, @EnableJpaRepositories, @EnableMongoRepositories
β”‚  β”œβ”€ jpa-entity-auditing.md      # @Entity*, @Id*, @CreatedDate, @Version, @EnableJpaAuditing
β”‚  β”œβ”€ queries.md                  # @Query, @Modifying, projections
β”‚  └─ converters.md               # @ReadingConverter, @WritingConverter
β”œβ”€ transactions/
β”‚  β”œβ”€ transactional-basics.md     # @Transactional, propagation/isolation
β”‚  └─ enable-tx.md                # @EnableTransactionManagement
β”œβ”€ security/
β”‚  β”œβ”€ enable-and-config.md        # @EnableWebSecurity, @EnableMethodSecurity
β”‚  β”œβ”€ method-security.md          # @PreAuthorize, @PostAuthorize, @Secured, @RolesAllowed
β”‚  └─ auth-context.md             # @AuthenticationPrincipal, @CurrentSecurityContext
β”œβ”€ async-scheduling/
β”‚  β”œβ”€ async.md                    # @Async, thread pool notes
β”‚  └─ scheduling.md               # @Scheduled, @EnableScheduling, cron
β”œβ”€ caching/
β”‚  └─ cache-annotations.md        # @EnableCaching, @Cacheable, @CachePut, @CacheEvict, @Caching
β”œβ”€ messaging/
β”‚  β”œβ”€ kafka.md                    # @EnableKafka, @KafkaListener, @SendTo
β”‚  β”œβ”€ rabbitmq.md                 # @EnableRabbit, @RabbitListener
β”‚  └─ jms.md                      # @JmsListener
β”œβ”€ actuator/
β”‚  └─ endpoints.md                # @Endpoint, @ReadOperation, @WriteOperation
└─ boot/
β”œβ”€ application-and-auto.md     # @SpringBootApplication, @AutoConfiguration
β”œβ”€ config-properties.md        # @ConfigurationProperties, @EnableConfigurationProperties
└─ conditional-on.md           # @ConditionalOnProperty/Bean/Class/MissingBean/Resource

ResponseEntity is not an annotation but belongs conceptually to REST responses β€” keep a mini reference for context.


🧠 Philosophy

  1. Organize by capability, not dependency.
    Jump straight to β€œtransactions” or β€œsecurity” without recalling which starter or module they live in.

  2. Keep pages thin. Each .md covers one concept cluster (e.g., mappings, transactions).
    Avoid giant scrolls; prefer clear entry points.

  3. Cross-link ruthlessly. Example:

  4. @Transactional β†’ links to data/queries.md
  5. @PreAuthorize β†’ links to security/method-security.md and core-di/conditions.md

  6. Reactive-ready. WebFlux lives in its own corner but reuses MVC annotations; highlight differences, don’t duplicate content.

  7. Boot awareness without dependency. Boot annotations live under /boot, but pages cross-reference corresponding Core features.


πŸͺΆ Page Template (per-annotation file)

# @AnnotationName β€” Cheatsheet

**Essence:** One-line summary of its purpose.  
**When to use:** Typical scenario or trigger condition.  
**Gotchas:** Common pitfalls or side effects.

## 1) Minimal Example

```java
// 10–20 lines max, compile-ready

Effect: Short description of runtime behavior.

2) Options that Matter

Option Default What It Changes Use When
name β€” Bean name Custom wiring

3) Interactions

  • Works with: @A, @B
  • Conflicts with: @C (explain why)
  • Boot tie-ins: @ConditionalOnProperty("...")

4) Troubleshooting

  • Symptom β†’ Likely cause β†’ Fix

See also: Links to related pages.

Optional front-matter for search and freshness tracking:

---
title: "@Transactional"
category: "transactions"
tags: ["propagation","isolation","rollback"]
tested_on: ["Spring Boot 3.3","Spring 6"]
last_update: 2025-10-22
---

πŸ—‚ Canonical Annotation Sets

Core & DI

@Component, @Service, @Repository, @Controller, @Configuration, @Bean, @Import, @Scope, @Lazy, @Autowired, @Qualifier, @Primary, @Value, @Profile, @Conditional, @PostConstruct, @PreDestroy, @EventListener

MVC / REST

@Controller, @RestController, @ControllerAdvice, @RequestMapping, @GetMapping, @PostMapping, @PutMapping, @DeleteMapping, @PathVariable, @RequestParam, @RequestBody, @ResponseBody, @ResponseStatus, @ExceptionHandler, @CrossOrigin

WebFlux

@EnableWebFlux, reactive controller differences (same annotations)

Validation

@Validated, @Valid, plus Jakarta annotations (@NotNull, @Size, @Email…)

Data

@Repository, @EnableJpaRepositories, @EnableMongoRepositories, @Query, @Modifying, @CreatedDate, @LastModifiedDate, @EnableJpaAuditing, @Entity, @Id, @GeneratedValue, @Version

Transactions

@Transactional, @EnableTransactionManagement

Security

@EnableWebSecurity, @EnableMethodSecurity, @PreAuthorize, @PostAuthorize, @Secured, @RolesAllowed, @AuthenticationPrincipal, @CurrentSecurityContext

Async / Scheduling

@Async, @EnableAsync, @Scheduled, @EnableScheduling

Caching

@EnableCaching, @Cacheable, @CachePut, @CacheEvict, @Caching

Messaging

Kafka β†’ @EnableKafka, @KafkaListener, @SendTo RabbitMQ β†’ @EnableRabbit, @RabbitListener JMS β†’ @JmsListener

Actuator

@Endpoint, @ReadOperation, @WriteOperation

Boot

@SpringBootApplication, @AutoConfiguration, @ConfigurationProperties, @EnableConfigurationProperties, @ConditionalOnProperty, @ConditionalOnBean, @ConditionalOnClass, etc.


🧭 index.md Template (master overview)

Spring Annotations β€” Master Map

Jump by capability:

Legend: Each page starts with β€œEssence / When to use / Gotchas” and ends with β€œTroubleshooting / See also”.


🧩 Maintenance Discipline

  • One page = one concept cluster. Avoid β€œeverything about @Controller in 500 lines” pages.

  • Short code, clear output. Examples must compile and demonstrate only the annotation’s core purpose.

  • Cross-references are mandatory. Use links liberally to show relationships and dependencies.

  • Track freshness. Use last_update: and framework version tags for periodic review when Spring 7+ arrives.


βœ… Outcome: A clean, extensible system for documenting Spring annotations β€” capable of absorbing future frameworks (Micronaut, Quarkus) by mirroring this blueprint under their own namespaces.