Urgent.News

What's breaking now, across hundreds of outlets.

Tech

What Happens Internally When a Spring Boot Application Starts?

Spring Boot makes application development remarkably simple. With just a few annotations and a main() method, we can start a complete Java application with dependency injection, embedded Tomcat, database connectivity, REST APIs, security, and much more. But have you ever wondered what actually happens behind the scenes when we execute this? @SpringBootApplication public class BankingApplication {…

When initiating a Spring Boot application, the process begins with the main() method of the application class. This method calls SpringApplication.run() with the application class and command-line arguments. Internally, SpringApplication performs several crucial steps to bootstrap the application:

1. SpringApplication Object Initialization: Before creating the application context, Spring Boot initializes a SpringApplication object. During this initialization, it identifies the application type (e.g., servlet-based or reactive), discovers and prepares application context initializers and listeners, and sets up the primary application sources and startup configuration.

2. Environment Preparation: Spring Boot prepares the application environment by loading configuration properties from various sources. These sources include application.properties and application.yml files, environment variables, command-line arguments, JVM system properties, and external configuration sources. The configuration values are accessible through Spring's Environment abstraction. Spring Boot also determines active application profiles, which allows for profile-specific configuration.

3. ApplicationContext Creation: With the environment prepared, Spring Boot creates the application context, which serves as the central container for the Spring application. Different application contexts are created depending on the application type. For servlet-based applications, an AnnotationConfigServletWebServerApplicationContext is typically used, while non-web applications may use a different implementation.

4. Bean Definitions and Dependency Injection: The application context contains the configuration for all beans in the application. Spring Boot identifies and registers bean definitions based on component scanning. Component scanning involves scanning the packages defined in the @ComponentScan annotation and discovering classes annotated with @Component, @Service, @Repository, or @Controller.

These classes are then registered as bean definitions in the application context. Dependency injection is handled by the Spring container, which resolves dependencies between beans based on their constructor parameters or setter methods.

5. Refreshing the Application Context: After bean definitions are registered, Spring Boot refreshes the application context. This step involves initializing and preparing the registered beans, allowing them to be injected with dependencies and ready for use. It also triggers the execution of application startup callbacks, such as InitializingBean and AfterSingletonsOf methods, which can perform additional initialization tasks.

6. Starting the Embedded Web Server: If the application is a servlet-based web application, Spring Boot starts the embedded web server, such as Tomcat. The server is configured based on the application properties, such as the server port. The embedded server listens for incoming requests and routes them to the appropriate handler methods based on the application's routing rules.

7. Application Readiness: Once the application context is fully refreshed and the embedded web server is started, the application becomes ready to receive requests. The application is now fully operational and can handle incoming HTTP requests through the embedded web server.

Rewritten by urgent.news; may contain errors — check the original.

Source: dev.to

Read the original at dev.to →

Report a problem with this story

More in Tech

From Tilda to KAVRK Technology: My Journey as a Developer

Hi, I'm Kunal Verma , a software developer from Tilda, Chhattisgarh . I grew up in Tilda-Neora, did my 12th (Mathematics) at Century Cement College, Baikunth, and studied engineering at RITEE – Raipur…

  • Kunal Verma, software developer from Tilda, Chhattisgarh
  • Developed projects in Laravel, API, network automation, AI, Android barcode attendance
  • Founded KAVRK Technology to provide software solutions for Chhattisgarh

Personal vs Organization Developer Account on Google Play, and How to Get Useful User Feedback Once Your Test Starts

Two decisions show up early for anyone shipping an Android app. The first happens before you write your store listing: personal vs organization developer account.

  • Personal developer accounts require 14-day closed test with 12+ testers
  • Organization accounts allow company name display on listing
  • Analyze feedback for specific, reproducible, evidenced, honest, contextual insights

Temp mail got my signups blocked, so I switched to a real inbox

I was trying to register a handful of developer sites from a script. The obvious move was a disposable inbox: create an address through an API, read the confirmation email through the same API, never…

  • The author tried registering developer sites using throwaway email accounts.
  • Some throwaway domains are blacklisted across anti-abuse lists.
  • Switching to a real mailbox resolved the silent email delivery failures.

A Practical Checklist for Mobile Browser Games Built With HTML5

Making an HTML5 game run on a desktop is easy. Making it feel good on a phone, in a mobile browser, with no install, is where most of the work hides.

  • Implement touch input using Pointer Events for seamless mouse, touch, and pen functionality
  • Test swiping gestures with line segments between touch points to avoid missed hits
  • Resize canvas using device pixel ratio while capping size for performance balance

More from Sunday, 29 November 2026 →