Docs LogoDocs

Core Annotations Cheat Sheet

A reference table of the core annotations you'll see across a typical Spring Boot codebase.

Core Annotations Cheat Sheet

Application & Configuration

AnnotationPurpose
@SpringBootApplicationEntry point; combines @Configuration, @EnableAutoConfiguration, @ComponentScan
@ConfigurationMarks a class as a source of bean definitions
@BeanDeclares a bean inside a @Configuration class
@ConfigurationPropertiesBinds a config block to a POJO
@Profile("dev")Only load a bean/config under a given active profile
@Conditional*Register a bean only if a condition holds (used heavily in auto-config)

Component Stereotypes

AnnotationPurpose
@ComponentGeneric Spring-managed bean
@ServiceBusiness/service layer bean (semantic alias of @Component)
@RepositoryData access layer bean; adds exception translation
@ControllerWeb layer bean returning views
@RestController@Controller + @ResponseBody; returns data (JSON) directly

Dependency Injection

AnnotationPurpose
@AutowiredInjects a dependency (optional on constructors since Spring 4.3 if there's only one constructor)
@Qualifier("beanName")Disambiguates when multiple beans of the same type exist
@PrimaryMarks a bean as the default choice when multiple candidates exist
@LazyDelays bean initialization until first use

Web / REST

AnnotationPurpose
@RequestMappingBase mapping for a controller/method (path, method, etc.)
@GetMapping / @PostMapping / @PutMapping / @DeleteMapping / @PatchMappingShortcut HTTP-method mappings
@PathVariableBinds a URI template variable to a method param
@RequestParamBinds a query parameter
@RequestBodyDeserializes the request body into a Java object
@ResponseBodySerializes the return value into the response body
@ResponseStatusSets the HTTP status for a response/exception
@CrossOriginEnables CORS for a controller/method

Validation

AnnotationPurpose
@Valid / @ValidatedTriggers bean validation on a @RequestBody or method params
@NotNull, @NotBlank, @Size, @Email, @Min/@MaxField-level constraints (from jakarta.validation)

Data / JPA (preview — full topic later)

AnnotationPurpose
@EntityMarks a class as a JPA-managed table
@Id / @GeneratedValuePrimary key + generation strategy
@ColumnColumn-level customization
@OneToMany, @ManyToOne, @ManyToManyRelationship mappings
@TransactionalWraps a method in a database transaction

A Common Beginner Mistake

Don't sprinkle @Autowired field injection everywhere just because it "compiles." Constructor injection (covered in the IoC/DI topic) is the convention in real codebases and what you should default to.

Last updated on July 15, 2026

On this page