0
0
Spring Bootframework~10 mins

Running a Spring Boot application in Spring Boot - Step-by-Step Execution

Choose your learning style9 modes available
Concept Flow - Running a Spring Boot application
Start Application
Spring Boot Main Method
SpringApplication.run()
Spring Boot Context Initialized
Embedded Server Starts
Application Ready to Serve Requests
This flow shows how starting a Spring Boot app runs the main method, initializes the context, starts the embedded server, and makes the app ready.
Execution Sample
Spring Boot
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

@SpringBootApplication
public class DemoApplication {
  public static void main(String[] args) {
    SpringApplication.run(DemoApplication.class, args);
  }
}
This code starts the Spring Boot application by running the main method which calls SpringApplication.run.
Execution Table
StepActionMethod CalledResultNext Step
1Start main methodmain()Entered main methodCall SpringApplication.run()
2Run Spring Boot appSpringApplication.run()Spring context initializingInitialize beans
3Initialize beansContext initializationBeans created and wiredStart embedded server
4Start embedded serverTomcat/Jetty startServer listening on port 8080Application ready
5Application readyN/AApp ready to accept requestsWait for requests
💡 Application runs continuously until stopped by user or error
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4Final
Application Contextnullinitializinginitializedinitializedrunning
Embedded Serverstoppedstoppedstartingrunningrunning
Key Moments - 2 Insights
Why does the application keep running after main method finishes?
Because the embedded server (like Tomcat) runs in the background, keeping the app alive as shown in steps 4 and 5 of the execution_table.
What does SpringApplication.run() actually do?
It initializes the Spring context, creates beans, and starts the embedded server, as detailed from step 2 to step 4 in the execution_table.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the state of the Application Context after step 3?
Anull
Binitialized
Cinitializing
Drunning
💡 Hint
Check the variable_tracker row for Application Context after Step 3
At which step does the embedded server start listening on port 8080?
AStep 2
BStep 3
CStep 4
DStep 5
💡 Hint
Look at the 'Result' column in execution_table for server listening info
If SpringApplication.run() fails to initialize beans, what step would fail?
AStep 3
BStep 4
CStep 2
DStep 5
💡 Hint
Bean creation happens during context initialization in Step 3
Concept Snapshot
Spring Boot apps start by running the main method.
Inside main, SpringApplication.run() initializes the app.
It creates the Spring context and beans.
Then it starts an embedded server (like Tomcat).
The app stays running, ready to handle requests.
Stop the app to end the server and process.
Full Transcript
Running a Spring Boot application begins with the main method. This method calls SpringApplication.run(), which initializes the Spring context and creates all necessary beans. After that, an embedded server such as Tomcat or Jetty starts listening on the default port 8080. The application remains running, ready to serve incoming requests until it is stopped by the user or an error occurs.