liveBook · Manning

SpringApplication.run

As explained in Spring in Action, Sixth Edition

SpringApplication.run is a Spring Boot entry-point method that bootstraps an application and creates its Spring application context.

SpringApplication.run is the standard Spring Boot entry point. It bootstraps the application and creates the Spring application context, where Spring discovers and manages application components. section 1.2.2

Typical bootstrap class

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

The call supplies two inputs:

  • TacoCloudApplication.class identifies the configuration class; using the bootstrap class is convenient and typical, but another configuration class is allowed. section 1.2.2
  • args passes command-line arguments into application startup. section 1.2.2
  • The surrounding @SpringBootApplication annotation enables automatic configuration and component scanning for annotated classes. section 1.2.2
Listing 1.2 The Taco Cloud bootstrap class
package tacos;
 
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
 
@SpringBootApplication                                        #1
public class TacoCloudApplication {
 
  public static void main(String[] args) {
    SpringApplication.run(TacoCloudApplication.class, args);  #2
  }
 
}

View the complete Taco Cloud bootstrap class with its annotation, main method, and SpringApplication.run call. section 1.2.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Explains the method’s purpose, arguments, and typical configuration-class choice without descending into bootstrapping internals.
Examples
Uses the TacoCloudApplication bootstrap class and its executable main method as the concrete implementation example.
What it assumes
Assumes basic Java main-method knowledge while introducing Spring Boot configuration and application-context concepts.
What you can do after
Operate a Spring Boot application by wiring its main method to SpringApplication.run.
How it connects
Connects SpringApplication.run with Spring application context, configuration classes, auto-configuration, component scanning, and command-line arguments.

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.