Spring Boot Basics

Basic Spring
≈ 2 min read

A minimal Boot application

The main idea of Spring Boot is to give the application a sensible starting configuration and run it like a regular Java program. The entry point remains the familiar main() method, while Spring Boot starts the Spring context and prepares what is needed for the selected application type.

@SpringBootApplication
public class Application {

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

The @SpringBootApplication annotation marks the application's main class. Calling SpringApplication.run() starts the Boot process and returns a ready ApplicationContext. From that point on, the application works with the same Spring container we already studied in Spring Core.

What Spring Boot does around startup

During startup, Boot determines the application configuration, starts component scanning, applies suitable automatic configuration, and creates beans. The exact set of actions depends on the project dependencies and settings, so two Boot applications may start differently even though their entry points look the same.

Spring Boot is not a separate container. Beans, Dependency Injection, lifecycle, and the other core mechanisms still belong to Spring. Boot primarily simplifies their configuration and startup.

Where to place the main class

The class with @SpringBootApplication is usually placed in the application's top-level package, with the remaining packages below it. This lets the standard component scan naturally cover the project code without extra configuration.