What is the primary purpose of the @SpringBootApplication annotation in a Spring Boot application?

  • To allow configuration classes.
  • To define a main method.
  • To enable Spring MVC support.
  • To enable component scanning.
The @SpringBootApplication annotation in Spring Boot is a convenience annotation that adds all of the following: @Configuration, @EnableAutoConfiguration, and @ComponentScan. Thus, it enables component scanning, allowing Spring to automatically discover and register beans. This is crucial for allowing the Spring context to be aware of all the components, services, repositories, etc. available in the project.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *