What is @SpringBootApplication in Spring Boot?
If you are using spring boot version below 1.2 than you need to add the below annotation in your application.
"Indicates a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning. This is a convenience annotation that is equivalent to declaring @Configuration, @EnableAutoConfiguration and @ComponentScan."
If you are using spring boot version below 1.2 than you need to add the below annotation in your application.
- @Configuration to enable Java-based configuration and mark your class a Configuration class.
- @ComponentScan to enable component scanning so that controllers and other components will automatically discovered and registered as bean in Spring's Application Context.
- @EnableAutoConfiguration to enable Spring Boot's auto-configuration feature.
But if you using spring boot 1.2 or above version, you just need to add the @SpringBootApplication annotation in your main class and your main class should be in your base package.
@SpringBootApplication = @Configuration + @ComponentScan + @EnableAutoConfiguration
No comments:
Post a Comment