25+ Spring and Spring Boot Annotations

Ramesh Fadatare
2 min readSep 22, 2024

--

In this course, I coverred 25+ spring and spring boot annotations with line-by-line coding in IntelliJ IDEA.

In the above YouTube video course, I explained below each annotation with line-by-line coding:

  1. @Component Annotation: Marks a Java class as a Spring component (bean), automatically registered in the Spring context.
  2. @Autowired Annotation: Automatically injects dependencies into beans, used for constructor, setter, or field injection.
  3. @Qualifier Annotation: Helps resolve conflict when there are multiple beans of the same type by specifying which bean to inject.
  4. @Primary Annotation: Sets a bean as the primary candidate when multiple beans of the same type are present.
  5. @SpringBootApplication Annotation: Combines three annotations (@Configuration, @EnableAutoConfiguration, and @ComponentScan) to simplify Spring Boot applications.
  6. @Bean and @Configuration Annotations: @Bean defines a Spring-managed bean inside a @Configuration class, which is used to configure Spring beans and settings.
  7. @Controller, @Service, and @Repository Annotations: Used to define beans at different layers of the application: @Controller for the presentation layer, @Service for the service layer, and @Repository for the persistence layer.
  8. @Lazy Annotation: Defers bean creation until it is first used (lazy initialization), improving performance in certain scenarios.
  9. @Scope Annotation: Defines the scope of a bean, such as singleton (default), prototype, request, session, etc.
  10. @Value Annotation: Injects values into fields or method arguments from property files or other sources.
  11. @PropertySource and @PropertySources Annotations: Load properties files into the Spring Environment for configuration.
  12. @ConfigurationProperties Annotation: Binds external configuration properties (e.g., from a properties or YAML file) to a Java object.
  13. @Controller and @ResponseBody Annotations: @Controller defines a class as a Spring MVC controller, while @ResponseBody converts Java objects into JSON or XML and writes them directly to the HTTP response.
  14. @RestController Annotation: A specialized version of @Controller that combines it with @ResponseBody to simplify RESTful web services.
  15. @RequestMapping Annotation: Maps web requests to specific handler methods or classes.
  16. @GetMapping Annotation: Maps HTTP GET requests to specific handler methods.
  17. @PostMapping and @RequestBody Annotations: Maps HTTP POST requests to methods, and @RequestBody binds the request body to a method parameter.
  18. @PutMapping Annotation: Maps HTTP PUT requests to methods, typically used for updating resources.
  19. @DeleteMapping Annotation: Maps HTTP DELETE requests to methods, used for deleting resources.
  20. @PathVariable Annotation: Binds a method parameter to a URI template variable.
  21. @RequestParam Annotation: Binds a method parameter to a web request parameter.
  22. @EnableAutoConfiguration Annotation: Enables Spring Boot’s auto-configuration feature, which automatically configures the application based on dependencies and environment.
  23. @ComponentScan Annotation: Configures where to scan for components (beans) in the Spring application context.

My Top 10+ Udemy Courses (Bestseller Courses): https://www.javaguides.net/p/my-udemy-courses-ramesh-fadatare.html

Java Guides blog: https://www.javaguides.net/

Company Website: https://rameshfadatare.com/

--

--

No responses yet