@SpringBootApplication Annotation

@SpringBootApplication annotation :  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.

  • @Configuration is used to enable Java-based configuration
  • @ComponentScan is used to enable component scanning so that spring components are discovered and are registered as beans in Spring’s Application Context.
  • @EnableAutoConfiguration is used to enable Spring Boot’s auto-configuration feature.

@SpringBootApplication = @Configuration + @EnableAutoConfiguration + @ComponentScan

This class also marks the entry point of the Spring Boot Application . We need to execute the main method to run the Spring Boot application.

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}

Leave a Reply

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