1. @SpringBootApplication Annotation

The @SpringBootApplication annotation is added to the main class of a Spring Boot application to run it as a standalone JAR or WAR. It is a composite annotation that combines three key annotations:

1.1 @Configuration

1.2 @EnableAutoConfiguration

1.3 @ComponentScan

Additional Annotation (Automatically Added)


2. Using the @SpringBootApplication Annotation

To run a Spring Boot application, a main class annotated with @SpringBootApplication is required. This class serves as the entry point for the application.

Example

package com.app;

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

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

Explanation