Spring is a popular Java framework for building web applications and provides a wide range of annotations for various purposes

  • @Autowired: This annotation is used to enable autowiring of dependencies in Spring. When used on a field, setter method, or constructor, Spring will automatically search for a bean of the required type in the application context and inject it into the class.
  • @Service: This annotation is used to indicate that a class is a service class. A service class typically contains business logic and is used to perform operations on the data.
  • @Repository: This annotation is used to indicate that a class is a repository class. A repository class is typically used to interact with a database and perform operations such as saving and retrieving data.
  • @Controller: This annotation is used to indicate that a class is a controller class. A controller class is typically used to handle incoming HTTP requests and return a response to the client.
  • @Component: This annotation is a general-purpose annotation that is used to indicate that a class is a component of the application and should be managed by the Spring framework.
  • @Bean: This annotation is used to indicate that a method is a factory method for creating an object that should be managed by the Spring framework.
  • @Transactional: This annotation is used to enable transaction management in Spring. When used on a method, it indicates that the method should be executed within a transaction.
  • @Cacheable: This annotation is used to enable caching in Spring. When used on a method, it indicates that the method’s result should be cached.
  • @Qualifier : This annotation is used to resolve conflicts when multiple beans of the same type are present in the application context.
  • @RestController: This annotation is a specialized version of the @Controller annotation, specifically designed for RESTful web services. It combines the functionality of @Controller and @ResponseBody annotations.
  • @RequestMapping: This annotation is used to map a specific URI pattern to a specific method in a controller class. It can be used at the class level and at the method level to specify the URI pattern that a method should handle.
  • @PathVariable: This annotation is used to bind a method argument to a URI template variable. It can be used to extract values from the URI and pass them as arguments to a controller method.
  • @RequestParam: This annotation is used to bind a method argument to a request parameter. It can be used to extract values from the query string of a request and pass them as arguments to a controller method.
  • @ModelAttribute: This annotation is used to bind a method argument to a model attribute. It can be used to extract values from the model and pass them as arguments to a controller method.
  • @SessionAttribute: This annotation is used to bind a method argument to a session attribute.
  • @CookieValue: This annotation is used to bind a method argument to a cookie value.
  • @JsonView : This annotation is used to apply view on a specific field of a specific class, in order to exclude or include some fields when sending the object as a response.
  • @JsonIgnore : This annotation is used to ignore a specific field when the object is sent as a response.
  • @Value : This annotation is used to inject a specific value, coming from properties file for example, into a field.
  • @Configuration: This annotation is used to indicate that a class is a configuration class. A configuration class is typically used to define beans and configure the Spring application.
  • @Primary: This annotation is used to indicate that a bean should be considered as the primary candidate for autowiring. This can be used to resolve conflicts when multiple beans of the same type are present in the application context.
  • @Scope: This annotation is used to specify the scope of a bean. The scope can be set to “singleton”, “prototype”, “request”, “session”, or “application”. The default scope is “singleton”.
  • @Lazy: This annotation is used to indicate that a bean should be initialized lazily. This means that the bean will not be created until it is first requested.
  • @PostConstruct These annotations are used to specify methods that should be called after a bean is constructed
  • @PreDestroy: These annotations are used to specify methods that should be called before a bean is destroyed,
  • @Async: This annotation is used to indicate that a method should be executed asynchronously.
  • @Scheduled: This annotation is used to schedule a method to be executed at a specific time or interval.
  • @Import: This annotation is used to import other configuration classes into a configuration class.
  • @Profile: This annotation is used to indicate that a bean or configuration should only be activated when a certain profile is active.