<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Abhishek Shahi</title>
    <description>The latest articles on DEV Community by Abhishek Shahi (@abhishek_shahi_9d131e426d).</description>
    <link>https://dev.to/abhishek_shahi_9d131e426d</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3678114%2F038df067-943b-4d55-858e-d0016c3fac22.png</url>
      <title>DEV Community: Abhishek Shahi</title>
      <link>https://dev.to/abhishek_shahi_9d131e426d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/abhishek_shahi_9d131e426d"/>
    <language>en</language>
    <item>
      <title>Boolean Field Becomes null in Spring Boot DTO? Here’s Why (And How to Fix It)</title>
      <dc:creator>Abhishek Shahi</dc:creator>
      <pubDate>Fri, 02 Jan 2026 19:57:06 +0000</pubDate>
      <link>https://dev.to/abhishek_shahi_9d131e426d/boolean-field-becomes-null-in-spring-boot-dto-heres-why-and-how-to-fix-it-4i39</link>
      <guid>https://dev.to/abhishek_shahi_9d131e426d/boolean-field-becomes-null-in-spring-boot-dto-heres-why-and-how-to-fix-it-4i39</guid>
      <description>&lt;p&gt;If you’re building REST APIs using Spring Boot, you may encounter a strange and frustrating issue:&lt;br&gt;
❓ The request JSON clearly sends a boolean value (true / false),&lt;br&gt;
but inside the DTO, the value becomes &lt;strong&gt;null&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No exception.&lt;/li&gt;
&lt;li&gt;No warning.&lt;/li&gt;
&lt;li&gt;No stack trace.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is not a bug in Spring Boot — it’s a Jackson + Java Bean naming trap that frequently appears in real-world applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;In this article, you’ll learn:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Why boolean values become null in Spring Boot DTOs&lt;/li&gt;
&lt;li&gt;- How Jackson maps JSON properties to Java fields&lt;/li&gt;
&lt;li&gt;- Why @JsonProperty fixes the issue&lt;/li&gt;
&lt;li&gt;- The recommended best practice to avoid this forever&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  The Problem: Boolean Value Is null in DTO
&lt;/h2&gt;

&lt;p&gt;Consider this request payload sent from the frontend:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "isActive": true
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Now look at the DTO:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class UserRequest {

    private Boolean isActive;

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Controller code:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@PostMapping("/user")
public void createUser(@RequestBody UserRequest request) {
    System.out.println(request.getIsActive());
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Actual Output&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;null

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;❌ JSON is correct&lt;br&gt;
❌ Mapping fails silently&lt;br&gt;
❌ Debugging becomes painful&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why This Happens (Jackson + Java Bean Rules)&lt;/strong&gt;&lt;br&gt;
Spring Boot uses Jackson to convert JSON into Java objects.&lt;/p&gt;

&lt;p&gt;Jackson does not rely only on field names — it follows &lt;strong&gt;Java Bean naming conventions&lt;/strong&gt;, which depend heavily on &lt;strong&gt;getter and setter names&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How Jackson Interprets Boolean Fields&lt;/strong&gt;&lt;br&gt;
For this field:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;private Boolean isActive;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jackson expects one of these method patterns:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Boolean isActive()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Boolean getActive()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But what we actually wrote:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public Boolean getIsActive()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;The Mismatch&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;JSON property: isActive&lt;br&gt;
Java property Jackson infers: active&lt;br&gt;
Because of this mismatch, Jackson fails to &lt;strong&gt;bind the value&lt;/strong&gt; — resulting in null.&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution 1: Use @JsonProperty (Quick Fix)
&lt;/h2&gt;

&lt;p&gt;You can explicitly tell Jackson how to map the JSON property.&lt;/p&gt;

&lt;p&gt;Fixed DTO Using &lt;strong&gt;@JsonProperty&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.fasterxml.jackson.annotation.JsonProperty;

public class UserRequest {

    @JsonProperty("isActive")
    private Boolean isActive;

    public Boolean getIsActive() {
        return isActive;
    }

    public void setIsActive(Boolean isActive) {
        this.isActive = isActive;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Result&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;✔ JSON maps correctly&lt;br&gt;
✔ DTO receives true / false&lt;br&gt;
✔ No more null&lt;/p&gt;
&lt;h2&gt;
  
  
  Solution 2: Best Practice (Highly Recommended)
&lt;/h2&gt;

&lt;p&gt;Instead of fixing the mapping, fix the design.&lt;/p&gt;

&lt;p&gt;Avoid starting boolean field names with is.&lt;br&gt;
&lt;strong&gt;Preferred DTO Design&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class UserRequest {

    private Boolean active;

    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Why This Is Better&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Fully Java Bean compliant&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No Jackson annotations required&lt;/li&gt;
&lt;li&gt;Cleaner, more readable DTOs&lt;/li&gt;
&lt;li&gt;Fewer bugs in large codebases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;boolean vs Boolean in Spring Boot DTOs&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Type&lt;/th&gt;
&lt;th&gt;Default Value&lt;/th&gt;
&lt;th&gt;Nullable&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;boolean&lt;/td&gt;
&lt;td&gt;false&lt;/td&gt;
&lt;td&gt;No&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Boolean&lt;/td&gt;
&lt;td&gt;null&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;When to Use What&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use boolean when the field is mandatory&lt;/li&gt;
&lt;li&gt;Use Boolean when the field is optional or tri-state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Common Interview Question&lt;/p&gt;

&lt;p&gt;Q: Why does Spring Boot map boolean JSON values to null?&lt;br&gt;
Answer:&lt;br&gt;
Because Jackson follows Java Bean naming conventions. Boolean fields prefixed with is can cause property name mismatches unless getters, setters, or @JsonProperty are defined correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;u&gt;Key Takeaways&lt;/u&gt;
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Boolean fields starting with is can silently break Jackson mapping&lt;/li&gt;
&lt;li&gt;Jackson relies on getter/setter naming, not field names&lt;/li&gt;
&lt;li&gt;@JsonProperty fixes the issue explicitly&lt;/li&gt;
&lt;li&gt;Best practice: avoid is prefix in DTO fields&lt;/li&gt;
&lt;li&gt;Always check DTO design before debugging controllers&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Final Advice
&lt;/h2&gt;

&lt;p&gt;If your JSON looks correct but your DTO value is null:&lt;br&gt;
👉 Check the getter and setter naming first.&lt;br&gt;
This small detail can save hours of debugging in Spring Boot applications.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>java</category>
      <category>springboot</category>
      <category>backend</category>
    </item>
    <item>
      <title>How Does a Web Server Work in Spring Boot? (Request–Response Flow Explained)</title>
      <dc:creator>Abhishek Shahi</dc:creator>
      <pubDate>Sun, 28 Dec 2025 21:20:44 +0000</pubDate>
      <link>https://dev.to/abhishek_shahi_9d131e426d/how-does-a-web-server-work-in-spring-boot-request-response-flow-explained-1fmf</link>
      <guid>https://dev.to/abhishek_shahi_9d131e426d/how-does-a-web-server-work-in-spring-boot-request-response-flow-explained-1fmf</guid>
      <description>&lt;h2&gt;
  
  
  A Complete Request–Response Flow Explained
&lt;/h2&gt;

&lt;p&gt;When we build REST APIs using Spring Boot, we often focus on writing controllers and services. But have you ever wondered &lt;strong&gt;what actually happens when a client hits an API endpoint like /api/users?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Behind the scenes, Spring Boot performs a series of well-orchestrated steps to handle the HTTP request and send back a response.&lt;br&gt;
In this blog, we’ll explore how a web server works in Spring Boot, starting from application startup to the final response returned to the client.&lt;/p&gt;
&lt;h2&gt;
  
  
  What Is a Web Server in Spring Boot?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;web server&lt;/strong&gt; is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Listening for incoming HTTP requests&lt;/li&gt;
&lt;li&gt;Forwarding them to the application&lt;/li&gt;
&lt;li&gt;Sending responses back to the client&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spring Boot simplifies this by providing an &lt;strong&gt;embedded web server&lt;/strong&gt;, meaning you don’t need to install or configure an external server separately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Common Embedded Servers in Spring Boot&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Tomcat (default)&lt;/li&gt;
&lt;li&gt;Jetty&lt;/li&gt;
&lt;li&gt;Undertow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you run a Spring Boot application, it automatically starts an embedded web server (usually Tomcat) on port 8080.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What Happens When You Start a Spring Boot Web Application?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before any HTTP request is handled, Spring Boot prepares the application environment.&lt;/p&gt;

&lt;p&gt;Here’s what happens internally:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JVM starts and executes the main() method&lt;/li&gt;
&lt;li&gt;SpringApplication.run() is invoked&lt;/li&gt;
&lt;li&gt;Spring creates the ApplicationContext&lt;/li&gt;
&lt;li&gt;Beans are initialized and dependency injection occurs&lt;/li&gt;
&lt;li&gt;Embedded web server (Tomcat) is created and started&lt;/li&gt;
&lt;li&gt;Server starts listening on a port (default: 8080)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;At this point, your application is ready to receive HTTP requests.&lt;/p&gt;
&lt;h2&gt;
  
  
  High-Level Request–Response Flow
&lt;/h2&gt;

&lt;p&gt;Let’s look at the overall picture before diving into details:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;- Client sends an HTTP request&lt;/li&gt;
&lt;li&gt;- Embedded server receives the request&lt;/li&gt;
&lt;li&gt;- Spring MVC processes the request&lt;/li&gt;
&lt;li&gt;- Controller executes business logic&lt;/li&gt;
&lt;li&gt;- Response is returned to the client&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now, let’s break this down step by step.&lt;/p&gt;
&lt;h2&gt;
  
  
  Step-by-Step: How Spring Boot Handles an HTTP Request
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Client Sends an HTTP Request&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A client (browser, Postman, frontend app) sends a request like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;GET /api/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This request contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP method (GET, POST, etc.)&lt;/li&gt;
&lt;li&gt;URL&lt;/li&gt;
&lt;li&gt;Headers&lt;/li&gt;
&lt;li&gt;Request body (if applicable)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Embedded Server Receives the Request&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The embedded Tomcat server listens on port 8080&lt;/li&gt;
&lt;li&gt;It receives the HTTP request&lt;/li&gt;
&lt;li&gt;The request is forwarded to the Spring framework
The server itself does not know about your controllers.
It simply passes the request to Spring.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 3: DispatcherServlet – The Front Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every Spring MVC application has a central component called &lt;strong&gt;DispatcherServlet&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It acts as the front controller&lt;/li&gt;
&lt;li&gt;All incoming HTTP requests pass through it&lt;/li&gt;
&lt;li&gt;It controls the entire request flow&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Responsibilities of DispatcherServlet:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Identify the correct controller&lt;/li&gt;
&lt;li&gt;Delegate request handling&lt;/li&gt;
&lt;li&gt;Manage response generation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This follows the Front &lt;strong&gt;&lt;a href="https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ru6ka8k8t0h02y9jz5cm.png" rel="noopener noreferrer"&gt;Controller Design Pattern&lt;/a&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Handler Mapping Finds the Controller&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Spring uses **HandlerMapping **to map URLs to controller methods.&lt;/p&gt;

&lt;p&gt;Example controller:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RestController
@RequestMapping("/api")
public class UserController {

    @GetMapping("/users")
    public List&amp;lt;User&amp;gt; getUsers() {
        return userService.getAllUsers();
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring maps:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/api/users  →  getUsers()
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 5: Controller, Service, and Repository Layers&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Once the controller is identified:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Controller&lt;/strong&gt; handles HTTP-specific logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Service&lt;/strong&gt; contains business logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Repository&lt;/strong&gt; interacts with the database&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This layered architecture ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Separation of concerns&lt;/li&gt;
&lt;li&gt;Better maintainability&lt;/li&gt;
&lt;li&gt;Easier testing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Response Conversion&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;After execution, the controller returns:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A Java object&lt;/li&gt;
&lt;li&gt;A String&lt;/li&gt;
&lt;li&gt;Or a ResponseEntity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spring then:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses &lt;strong&gt;HttpMessageConverters&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Converts Java objects into JSON (using Jackson)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example response:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[
  {
    "id": 1,
    "name": "Abhishek"
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step 7: Response Is Sent Back to the Client&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;DispatcherServlet sends the response back to Tomcat&lt;/li&gt;
&lt;li&gt;Tomcat sends the HTTP response to the client&lt;/li&gt;
&lt;li&gt;The request–response cycle completes&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why DispatcherServlet Is So Important
&lt;/h2&gt;

&lt;p&gt;The **DispatcherServlet **is the backbone of Spring MVC because it:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Centralizes request handling&lt;/li&gt;
&lt;li&gt;Enables loose coupling&lt;/li&gt;
&lt;li&gt;Makes applications extensible using filters and interceptors&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Interview-ready statement:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;DispatcherServlet acts as the traffic controller of a Spring Boot web application.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Spring Boot starts an embedded web server automatically&lt;/li&gt;
&lt;li&gt;All HTTP requests are handled through DispatcherServlet&lt;/li&gt;
&lt;li&gt;HandlerMapping identifies the correct controller&lt;/li&gt;
&lt;li&gt;Business logic executes in service layers&lt;/li&gt;
&lt;li&gt;Responses are converted and returned to the client&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Understanding &lt;strong&gt;how a web server works in Spring Boot&lt;/strong&gt; gives you deeper insight into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debugging production issues&lt;/li&gt;
&lt;li&gt;Designing scalable APIs&lt;/li&gt;
&lt;li&gt;Answering Spring MVC interview questions confidently&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you understand this flow, Spring Boot stops feeling like magic—and starts making complete sense.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>java</category>
      <category>backend</category>
      <category>springboot</category>
    </item>
    <item>
      <title>Spring Boot Application Startup Flow: What Happens Behind the Scene</title>
      <dc:creator>Abhishek Shahi</dc:creator>
      <pubDate>Thu, 25 Dec 2025 10:56:14 +0000</pubDate>
      <link>https://dev.to/abhishek_shahi_9d131e426d/spring-boot-application-startup-flow-what-happens-behind-the-scene-2bj1</link>
      <guid>https://dev.to/abhishek_shahi_9d131e426d/spring-boot-application-startup-flow-what-happens-behind-the-scene-2bj1</guid>
      <description>&lt;p&gt;When you run a Spring Boot application, a lot of things happen automatically behind the scenes.&lt;br&gt;
From JVM startup to bean creation, auto-configuration, and embedded server initialization, Spring Boot handles everything for you.&lt;/p&gt;
&lt;h2&gt;
  
  
  Spring Boot Application Startup Flow
&lt;/h2&gt;

&lt;p&gt;In this blog, I’ll explain the complete startup flow of a Spring Boot application, step by step, in a way that finally made sense to me.&lt;/p&gt;
&lt;h2&gt;
  
  
  1. JVM Starts and Calls the main() Method
&lt;/h2&gt;

&lt;p&gt;Every Spring Boot application starts like any normal Java application.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The JVM starts&lt;/li&gt;
&lt;li&gt;It loads the class that contains the main() method&lt;/li&gt;
&lt;li&gt;The main() method is executed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;example&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@SpringBootApplication
public class MyAppApplication {

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

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this point, Spring Boot has not started yet.&lt;br&gt;
We are still in plain Java.&lt;/p&gt;
&lt;h2&gt;
  
  
  2. SpringApplication.run() Is the Real Entry Point
&lt;/h2&gt;

&lt;p&gt;The real Spring Boot journey begins when:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SpringApplication.run(MyAppApplication.class, args);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;is called.&lt;/p&gt;

&lt;p&gt;Internally, this method does a lot of work, but conceptually it does three important things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a SpringApplication object&lt;/li&gt;
&lt;li&gt;Prepares the application environment&lt;/li&gt;
&lt;li&gt;Creates and refreshes the ApplicationContext&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  3. SpringApplication Object Is Created
&lt;/h2&gt;

&lt;p&gt;Spring Boot first creates a SpringApplication object.&lt;/p&gt;

&lt;p&gt;This object is responsible for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Determining whether the app is web or non-web&lt;/li&gt;
&lt;li&gt;Loading ApplicationContextInitializers&lt;/li&gt;
&lt;li&gt;Registering ApplicationListeners&lt;/li&gt;
&lt;li&gt;Preparing the Environment (properties, profiles)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it as the bootstrapping brain of Spring Boot.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Environment Is Prepared
&lt;/h2&gt;

&lt;p&gt;Before any beans are created, Spring Boot prepares the Environment.&lt;/p&gt;

&lt;p&gt;This includes:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;application.properties / application.yml&lt;/li&gt;
&lt;li&gt;Active profiles (dev, prod, etc.)&lt;/li&gt;
&lt;li&gt;JVM arguments&lt;/li&gt;
&lt;li&gt;OS environment variables&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This step is important because many configurations depend on environment values.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. ApplicationContext Is Created
&lt;/h2&gt;

&lt;p&gt;Next, Spring Boot creates the ApplicationContext, which is the core container of Spring.&lt;/p&gt;

&lt;p&gt;Depending on the application type:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Web app → AnnotationConfigServletWebServerApplicationContext&lt;/li&gt;
&lt;li&gt;Non-web app → AnnotationConfigApplicationContext&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The ApplicationContext:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Manages beans&lt;/li&gt;
&lt;li&gt;Handles dependency injection&lt;/li&gt;
&lt;li&gt;Controls the application lifecycle&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  6. Component Scanning Begins
&lt;/h2&gt;

&lt;p&gt;Now Spring starts component scanning.&lt;/p&gt;

&lt;p&gt;It scans packages starting from the class annotated with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@SpringBootApplication

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;During scanning, Spring detects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;@Component&lt;/li&gt;
&lt;li&gt;@Service&lt;/li&gt;
&lt;li&gt;@Repository&lt;/li&gt;
&lt;li&gt;@Controller&lt;/li&gt;
&lt;li&gt;@RestController&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These classes are registered as beans inside the ApplicationContext.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Bean Creation and Dependency Injection
&lt;/h2&gt;

&lt;p&gt;Once components are detected:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Beans are created&lt;/li&gt;
&lt;li&gt;Dependencies are injected using: 
Constructor injection
Field injection
Setter injection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is where Inversion of Control (IoC) actually happens.&lt;/p&gt;

&lt;p&gt;Spring now manages the lifecycle of your objects.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Auto-Configuration in Spring Boot
&lt;/h2&gt;

&lt;p&gt;This is the most powerful feature of Spring Boot.&lt;/p&gt;

&lt;p&gt;Spring Boot checks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What dependencies are present on the classpath&lt;/li&gt;
&lt;li&gt;What properties are configured&lt;/li&gt;
&lt;li&gt;What conditions are satisfied&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Based on this, &lt;strong&gt;it automatically configures beans&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If Spring Web is present → configure DispatcherServlet&lt;/li&gt;
&lt;li&gt;If JPA is present → configure EntityManager&lt;/li&gt;
&lt;li&gt;If Tomcat is present → configure embedded server
All of this happens using &lt;strong&gt;conditional annotations.&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  9. Embedded Server Starts
&lt;/h2&gt;

&lt;p&gt;For web applications:&lt;br&gt;
An embedded server (Tomcat/Jetty/Netty) is started&lt;br&gt;
Server is bound to the configured port (default: 8080)&lt;br&gt;
DispatcherServlet is initialized&lt;br&gt;
Now your application is &lt;strong&gt;ready to handle HTTP requests.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Application Is Ready🚀
&lt;/h2&gt;

&lt;p&gt;At this point:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All beans are initialized&lt;/li&gt;
&lt;li&gt;Auto-configuration is complete&lt;/li&gt;
&lt;li&gt;Server is running&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spring Boot publishes an ApplicationReadyEvent, signaling that the app has fully started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Spring Boot Startup Flow Summary
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;JVM starts and runs main() method&lt;/li&gt;
&lt;li&gt;SpringApplication.run() bootstraps the app&lt;/li&gt;
&lt;li&gt;Environment and profiles are prepared&lt;/li&gt;
&lt;li&gt;ApplicationContext is created&lt;/li&gt;
&lt;li&gt;Components are scanned and beans are created&lt;/li&gt;
&lt;li&gt;Auto-configuration configures required beans&lt;/li&gt;
&lt;li&gt;Embedded server starts&lt;/li&gt;
&lt;li&gt;Application becomes ready to serve requests&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Why Understanding This Matters
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Understanding the startup flow helps you:&lt;/li&gt;
&lt;li&gt;Debug startup errors&lt;/li&gt;
&lt;li&gt;Answer interview questions confidently&lt;/li&gt;
&lt;li&gt;Customize Spring Boot behavior&lt;/li&gt;
&lt;li&gt;Stop treating Spring Boot as a black box
This explanation helped me finally understand what Spring Boot is actually doing for us instead of just memorizing annotations.&lt;/li&gt;
&lt;/ul&gt;

&lt;blockquote&gt;
&lt;p&gt;If you’re also learning Spring Boot, I hope this clears things up for you 🙂&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>springboot</category>
      <category>beginners</category>
      <category>java</category>
      <category>backend</category>
    </item>
  </channel>
</rss>
