Annotations Articles
Articles organizing the roles, differences, and correct usage of frequently encountered annotations in Spring Boot.
-
Differences Between @Service, @Repository, and @Controller in Spring Boot and How to Use Them - From Their Relationship with @Component to Exception Translation
@Service, @Repository, and @Controller are all derived from @Component, but they differ in actual effects beyond DI registration, such as exception translation in @Repository and handler mapping in @Controller. This article demonstrates the differences with source code and verification code, and explains the criteria for choosing annotations for each layer with a quick reference table.
-
How to Implement Group Validation and Method Validation with Spring Boot's @Validated Annotation
A step-by-step guide to safely integrating group validation and Service-layer method validation using Spring Boot's @Validated, covering the differences from @Valid and exception handling.
-
How to Implement Validation Simply with the Spring Boot @Valid Annotation - Usage and Error Handling
A concise guide with code to using the Spring Boot @Valid annotation. Covers automatic validation with @RequestBody, key constraints such as @NotBlank/@Email/@Size, recursive validation of nested DTOs, the difference from @Validated, and standardizing error responses for MethodArgumentNotValidException with implementation examples.
-
What Are @Configuration and @Bean in Spring Boot? Differences from @Component and How to Use Them
A practical guide to the differences between @Configuration and @Bean in Spring Boot and when to use them versus @Component, with real examples. Covers registering beans from external libraries, injecting arguments into @Bean methods, CGLIB proxy behavior, and replacing beans in tests, with clear decision criteria.
-
Spring Boot @Scheduled: Cron Jobs, fixedRate, and fixedDelay Explained
Learn how to schedule tasks in Spring Boot using @Scheduled. Covers cron expressions, fixedRate vs fixedDelay, timezone settings, and how to avoid common pitfalls like duplicate execution and silent failures.
-
What Is @Component in Spring Boot? Differences from @Bean and How to Use It
A beginner-friendly guide to @Component in Spring Boot. Learn the differences from @Bean, criteria for choosing between them, how it relates to @Service and @Repository, and practical usage including constructor injection, with code examples.