Sobes.tech
Junior — Middle

Can you list the main annotations used in Spring for configuration and component management?

sobes.tech AI

Answer from AI

In the Spring Framework, the following main annotations are often used for configuring and managing components:

  • @Component — declares a class as a Spring component, which will be automatically detected and registered in the context.
  • @Service — a specialized version of @Component for the service layer.
  • @Repository — a specialized version of @Component for the data access layer.
  • @Controller — for marking controllers in MVC.
  • @Autowired — for automatic dependency injection.
  • @Configuration — indicates that the class contains bean definitions.
  • @Bean — declares a method that creates a bean.
  • @Qualifier — specifies which bean to inject when there are multiple candidates.

These annotations help manage the lifecycle and dependencies of components in the application.