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.
Loading...
Related Quiz
- Which annotation is used to test only the web layer in a Spring Boot application?
- To perform unit testing on the web layer of a Spring Boot application without loading the complete context, use the _____ annotation.
- In a Spring Data JPA repository, which annotation is used to annotate a custom query when the derived query mechanism is not sufficient?
- The Spring Cloud component _____ provides a simple, scalable, and flexible way to route API requests to microservices.
- In Spring Boot, how do you handle conflicts between properties defined in the application properties file and environment variables?