π§© 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
ResponseEntityis not an annotation but belongs conceptually to REST responses β keep a mini reference for context.
π§ Philosophy¶
-
Organize by capability, not dependency.
Jump straight to βtransactionsβ or βsecurityβ without recalling which starter or module they live in. -
Keep pages thin. Each
.mdcovers one concept cluster (e.g., mappings, transactions).
Avoid giant scrolls; prefer clear entry points. -
Cross-link ruthlessly. Example:
@Transactionalβ links todata/queries.md-
@PreAuthorizeβ links tosecurity/method-security.mdandcore-di/conditions.md -
Reactive-ready. WebFlux lives in its own corner but reuses MVC annotations; highlight differences, donβt duplicate content.
-
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:
- Core & DI β Stereotypes Β· Beans Β· Profiles
- MVC / REST β Controllers Β· Mappings Β· Errors
- WebFlux β Enable & Config
- Validation β @Valid & @Validated
- Data β Repositories Β· Queries
- Transactions β @Transactional
- Security β Method Security
- Async / Scheduling β @Async Β· @Scheduled
- Caching β Cache annotations
- Messaging β Kafka Β· RabbitMQ
- Actuator β Custom endpoints
- Boot β Auto-Config Β· ConfigurationProperties
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.