@SpringBootApplication annotation indicates a configuration class that declares one or more @Bean methods and also triggers auto-configuration and component scanning.
The @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScan with their default attributes.
@SpringBootApplication Example
@SpringBootApplication annotation example: We use this annotation to mark the main class of a Spring Boot application:
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication // same as @Configuration @EnableAutoConfiguration @ComponentScan
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Read more about @SpringBootApplication annotation on Spring Boot @SpringBootApplication Annotation with Example.
@Configuration
Spring @Configuration annotation is part of the spring core framework. Spring Configuration annotation indicates that the class has @Bean definition methods. So Spring containers can process the class and generate Spring Beans to be used in the application.Read more at https://www.javaguides.net/2018/09/spring-configuration-annotation-with-example.html
@EnableAutoConfiguration
@EnableAutoConfiguration annotation tells Spring Boot to “guess” how you want to configure Spring, based on the jar dependencies that you have added.Read more at https://www.javaguides.net/2018/09/spring-boot-enableautoconfiguration-annotation-with-example.html
Comments
Post a Comment