└── README.md /README.md: -------------------------------------------------------------------------------- 1 | # List of Spring Framework and Spring Boot Annotations 2 | Check out all the spring core, spring MVC, spring boot, spring cloud, and spring data jpa annotations with examples, tutorials, and guides. Click on each annotation to learn in-depth with examples. I will continue adding more annotations here. 3 |

1. Spring Core Annotations

4 |
@Component Annotation 5 | : The @Component annotation indicates that an annotated class is a “spring bean/component”. The @Component annotation tells the Spring container to automatically create Spring bean. 6 |

7 |
@Autowired Annotation 8 | : The @Autowired annotation is used to inject the bean automatically. The @Autowired annotation is used in constructor injection, setter injection, and field injection 9 |

10 |
@Qualifier Annotation 11 | : @Qualifier annotation is used in conjunction with Autowired to avoid confusion when we have two or more beans configured for the same type. 12 |

13 |
@Primary Annotation 14 | : We use @Primary annotation to give higher preference to a bean when there are multiple beans of the same type. 15 |

16 |
@Bean Annotation 17 | : @Bean annotation indicates that a method produces a bean to be managed by the Spring container. The @Bean annotation is usually declared in the Configuration class to create Spring Bean definitions. 18 |

19 |
@Lazy Annotation 20 | : By default, Spring creates all singleton beans eagerly at the startup/bootstrapping of the application context. You can load the Spring beans lazily (on-demand) using @Lazy annotation. 21 |

22 |
@Scope Annotation 23 | : The @Scope annotation is used to define the scope of the bean. We use @Scope to define the scope of a @Component class or a @Bean definition.  24 |

25 |
@Value Annotation 26 | : Spring @Value annotation is used to assign default values to variables and method arguments. 27 |

28 |
@PropertySource Annotation 29 | : Spring @PropertySource annotation is used to provide properties files to Spring Environment. Spring PropertySource annotation is repeatable, which means you can have multiple PropertySource on a Configuration class. 30 |

31 |

2. Spring MVC Web Annotations

32 |
@Controller Annotation 33 | : Spring provides @Controller annotation to make a Java class as a Spring MVC controller. The @Controller annotation indicates that a particular class serves the role of a controller.  34 |

35 |
@ResponseBody Annotation 36 | : The @ResponseBody annotation tells a controller that the object returned is automatically serialized into JSON and passed back into the HttpResponse object.  37 |

38 |
@RestController Annotation 39 | : Spring 4.0 introduced @RestController, a specialized version of the @Controller which is a convenience annotation that does nothing more than add the @Controller and @ResponseBody annotations.  40 |

41 |
@RequestMapping Annotation 42 | : @RequestMapping is the most common and widely used annotation in Spring MVC. It is used to map web requests onto specific handler classes and/or handler methods.  43 |

44 |
@GetMapping Annotation 45 | : The GET HTTP request is used to get single or multiple resources and @GetMapping annotation for mapping HTTP GET requests onto specific handler methods.  46 |

47 |
@PostMapping Annotation 48 | : The POST HTTP method is used to create a resource and @PostMapping annotation for mapping HTTP POST requests onto specific handler methods.  49 |

50 |
@PutMapping Annotation 51 | : The PUT HTTP method is used to update the resource and @PutMapping annotation for mapping HTTP PUT requests onto specific handler methods.  52 |

53 |
@DeleteMapping Annotation 54 | : The DELETE HTTP method is used to delete the resource and @DeleteMapping annotation for mapping HTTP DELETE requests onto specific handler methods.  55 |

56 |
57 | @PatchMapping Annotation 58 | : The PATCH HTTP method is used to update the resource partially and the @PatchMapping annotation is for mapping HTTP PATCH requests onto specific handler methods.
59 |

60 |
@PathVariable Annotation 61 | : Spring boot @PathVariable annotation is used on a method argument to bind it to the value of a URI template variable. 62 |

63 |
@ResponseStatus Annotation 64 | : The @ResponseStatus annotation is a Spring Framework annotation that is used to customize the HTTP response status code returned by a controller method in a Spring MVC or Spring Boot application. 65 |

66 |
@Service Annotation 67 | : @Service annotation is used to create Spring beans at the Service layer. 68 |

69 |
@Repository Annotation 70 | : @Repository is used to create Spring beans for the repositories at the DAO layer. 71 |

72 |
@Controller Annotation 73 | : @Controller is used to create Spring beans at the controller layer. 74 |

75 |

3. Spring Boot Annotations

76 |
@SpringBootApplication annotation 77 | : The @SpringBootApplication annotation is a core annotation in the Spring Boot framework. It is used to mark the main class of a Spring Boot application. This annotation is a combination of three other annotations: @Configuration, @EnableAutoConfiguration, and @ComponentScan. 78 |

79 |
@EnableAutoConfiguration annotation 80 | : @EnableAutoConfiguration annotation enables Spring Boot's auto-configuration feature, which automatically configures the application based on the classpath dependencies and the environment. 
81 |

82 |
@Async Annotation 83 | : @Async annotation can be provided on a method so that invocation of that method will occur asynchronously. 84 |

85 |

4. Spring Data JPA Annotations

86 |
@Query Annotation 87 | : In Spring Data JPA, the @Query annotation is used to define custom queries. It allows developers to execute both JPQL (Java Persistence Query Language) and native SQL queries. 88 |

89 |
90 |

5. Spring Boot Testing Annotations

91 |
@SpringBootTest annotation 92 | : Spring Boot provides @SpringBootTest annotation for Integration testing. This annotation creates an application context and loads the full application context. 93 |

94 |
@DataJpaTest annotation 95 | : Spring Boot provides the @DataJpaTest annotation to test the persistence layer components that will autoconfigure the in-memory embedded database for testing purposes. 96 |

97 |
@WebMvcTest annotation 98 | :The @WebMvcTest annotation is used to perform unit tests on Spring MVC controllers. It allows you to test the behavior of controllers, request mappings, and HTTP responses in a controlled and isolated environment. 99 |

100 | --------------------------------------------------------------------------------