<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by irfan arshad on Medium]]></title>
        <description><![CDATA[Stories by irfan arshad on Medium]]></description>
        <link>https://medium.com/@mirfanarshad?source=rss-6b06f9eac049------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*e46kkt3Qzezu7mwcSx8uAQ.jpeg</url>
            <title>Stories by irfan arshad on Medium</title>
            <link>https://medium.com/@mirfanarshad?source=rss-6b06f9eac049------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 03 Dec 2026 12:28:21 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mirfanarshad/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[JAVA Servlet Spring Boot MVC]]></title>
            <link>https://mirfanarshad.medium.com/java-servlet-spring-boot-mvc-1e62a5ceee12?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/1e62a5ceee12</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[serverless]]></category>
            <category><![CDATA[banking]]></category>
            <category><![CDATA[java-servlet]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Tue, 17 Nov 2026 12:52:48 GMT</pubDate>
            <atom:updated>2026-11-17T12:52:48.584Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpTjm3p_LLjXyDKbkm4-MQ.png" /></figure><p>When I first start learning the Web Development. I keep hearing one term repeatedly: <strong>Servlet</strong></p><p>Today We all aware of the need of creating dynamic web pages i.e the one which have the capability to change the site content according to the time or are able to generate the contents according to the request received by the client. If you like coding in java then we will happy to know that using JAVA there also exists a way to generate dynamic web pages and that way is java servlet. But before we move forward with our topic lets first understand the need for server-side extenstion.</p><p>Servlets are the java program that runs on the java-enable web server(such as Apache Tomcat) or application server. They are used to handle the request obtained from the web server, process the request, produce the response then send response back to webserver.</p><p><em>Before diving deeper into Servlets, it’s important to understand the role of a Web Server, a Web Appliacation, and how they work together to process client requests. These concepts are commonly discussed in Java fresher interviews.</em></p><h3>What is WEB APPLIACTION, WEB SERVER and SERVLET???</h3><ol><li><strong>Web Application: </strong>The application which is developed only by using web-related technologies (like HTML, XML, JavaScript, AngularJS, servlets, JSP, etc.) is called a web application.</li><li><strong>Web Server: </strong>Once we had developed the web application, we required special software to run the application. This special software is nothing but a web server.</li><li><strong>Servlet: </strong>A Servlet is a Java class that runs inside a web server (such as Apache Tomcat) and handles HTTP requests from clients.</li><li><strong>Web Container:</strong> It is responsible for managing the complete lifecycle of a servlet</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/765/1*MO6y1Ic42hfIgrDXjEgMvw.png" /></figure><h3>Servlet Lifecycle</h3><p>The following figure illustrates the lifecycle of a servlet. Since it was created, processed requests from the users, until it was destroyed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*-p1tvqq4UiPKmkCkAo8M_Q.png" /></figure><h3><strong>There are 5 step:</strong></h3><p>&gt;&gt; Load Servlet Class.</p><p>&gt;&gt; Create Instance of Servelet</p><p>&gt;&gt; Call the Servlet init() method</p><p>&gt;&gt; Call the Servlet destroy method</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GJCQFBMeCcOiCEqr05kbNw.png" /></figure><p>Step 1,2 and 3 are executed only once, when the servlet is initially loaded. By default the servlet is not loaded until the first request is received for it. You can force the container to load the servlet when the container starts up though.</p><p>Step 4 is executed multiple time — once for every HTTP request to the servlet.</p><p>Step 5 is executed when the servlet container unloads the servlet</p><p><strong>You can see the following illustration to better understanding the lifecycle of the servlet.</strong></p><p>When the request of users to Servlet, the servlet will call the method of service() of serve the requirement of users, the service will call either doGet() ot doPost()</p><p>Thus, when users requested a servlet, the servlet will be created are the time of the first request, and will simultaneously call the init() method of servlet to initialize it, init() method is called only one time. Method of distroy() is used to destroy the servlet, it will be called only once when removing deployment(undeployed) of web application or stop the web server</p><h3><strong>Properties of servlet:</strong></h3><p><strong>&gt;&gt; </strong>Servlets work on server side</p><p><strong>&gt;&gt;</strong> Servlets are capable of handling the complex requests obtained from web server.</p><h3><strong>Execution of servlets:</strong></h3><p><strong>Execution of Servlets involves six basic steps”</strong></p><p>&gt;&gt; The client send the request to the web server</p><p>&gt;&gt; The web server receives the request</p><p>&gt;&gt; The web server passes the request to the corresponding servlet.</p><p>&gt;&gt; The servlet sends the response back to the web server</p><p>&gt;&gt; The web server sends the response back to the client and the client browser displays it on the screen.</p><p>Servlet Architecute</p><p>The following digram shows the servlet architecture:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/718/1*vI49rRtQdcMpC2Ai20rzJQ.png" /></figure><p>In a web application, we are talking about HTTP requests and HTTP responses. When something is typed in the address bar of a browser, it sends a request to the web server. The web server returns a response based on the request, and the browser displays the page.</p><ul><li>Tomcat is responsible for managing Servlet and Filter instances within a web application.</li><li>Tomcat invokes various life-cycle methods of Servlets and Filters, such as init(), service(), and destroy().</li><li>For HTTP requests, HttpServlet handles the request processing.</li><li>Depending on the HTTP request method (GET, POST, etc.), the corresponding doXXX() method is invoked by the servlet container.</li><li>To enable Spring MVC, the DispatcherServlet from the Spring MVC jar needs to be declared in the web.xml configuration file of the web application.</li><li>The DispatcherServlet is configured to listen for requests matching a specified URL pattern, typically “*”, which means all requests are mapped to the DispatcherServlet for processing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D0POHglFwoIYymEZcw7FNw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0spFtVnoXb6N6K6y0m9nmg.png" /></figure><h3>Request processing flow</h3><p>Following your numbered diagram, the request lifecycle looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PnzfGiwO-dtqlal2mIr-SQ.png" /></figure><ol><li>Browser gives <strong>request to Spring MVC</strong> Web Application.</li></ol><p>2. Dispatcher Servlet (sometimes called Front controller ) takes and traps the request &amp; applies the <strong>Common System Services</strong> like Security, Logging, and Auditing.</p><p>3. Dispatcher Servlet delegates the request to <strong>Handler Mapping.</strong></p><p>4. Once handler mapping gets the request maps the request with <strong>Handler Class/Controller class</strong> and returns the <strong>Handler Class Bean Id</strong>. Now dispatcher servlet receives the bean id and somehow gets the handler class object and calls method of that object so that control goes to handler class.</p><p>5. Handler class/Controller class creates command class object and perform request wrapping .i.e. receives the form data and stores (also called request wrapping) into <strong>Command Class</strong> object. Actually command class is java bean whose object holds received the form data.( if there is form data).</p><p>6. Now handler class <strong>executes its own business logic</strong> or talks with <strong>Service or DAO</strong> class get the output by processing the request.</p><p>7. Now handler class returns <strong>Logical View Name</strong> to dispatcher servlet.</p><p>8. Now dispatcher servlet take the Logical view name and returns <strong>View Interface Implementation Class Object</strong> having <strong>Physical View</strong> .it means dispatcher servlet uses <strong>View Resolver</strong> to get <strong>View Object</strong> having view layer technology and resource.</p><p>9. Dispatcher servlet calls <strong>Render ()</strong> method on that object.</p><p>10. Now <strong>Render ()</strong> method , transfer the control to <strong>View Resource</strong> for getting physical view like JSP, html etc.</p><p>11. JSP contains the presentation logic and format the result and send formatted result to browser as response.</p><h3>Advantages of Spring MVC Framework</h3><p>Now, let’s see what the advantages of Spring MVC are.</p><ol><li>It uses a lightweight container for creating and deploying web applications.</li><li>It offers various options to configure the framework and application classes. This makes it easy to reference them in different contexts.</li><li>It offers convenient testing options and the ability to use annotations for redirecting pages, providing flexibility in mapping.</li><li>It will enable rapid and parallel development and encourages the reuse of existing business objects.</li><li>It has built-in support for form handling, validation, and <a href="https://www.naukri.com/code360/library/vaadin-23-data-binding"><strong>data binding</strong></a>.</li></ol><h3>Disadvantages of Spring MVC Framework</h3><p>After the advantages, let’s see what the disadvantages of Spring MVC are.</p><ol><li>It can be challenging to set up and configure, especially for beginners.</li><li>It may experience performance issues when handling high traffic or large amounts of data.</li><li>It can be overbearing for small projects, as it may include more functionality than is needed.</li><li>It can be difficult to troubleshoot and debug issues as the framework is large and complex.</li><li>It requires developers to invest time and effort to become proficient as it has a steeper learning curve.</li></ol><p>Want to Hire/Connect? <a href="https://www.linkedin.com/in/muhammad-irfan-arshad-a8427a71/"><strong><em>LinkedIn</em></strong></a></p><ul><li><em>A clap would be highly appreciated if you liked what you just read. You can be generous in clapping; it shows me how much you enjoyed this story. And if you didn’t like it? Please do comment</em>😋<em>!</em></li><li>* <strong>Follow me on </strong><a href="https://www.linkedin.com/in/muhammad-irfan-arshad-a8427a71/"><strong><em>LinkedIn</em></strong></a><strong>. Have a Happy Learning.</strong> :)***</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1e62a5ceee12" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LDEP Authentication: How it Work and Best Practice]]></title>
            <link>https://mirfanarshad.medium.com/ldep-authentication-how-it-work-and-best-practice-d43304ba9a09?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/d43304ba9a09</guid>
            <category><![CDATA[active-directory]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[ldap-authentication]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Sun, 15 Nov 2026 08:05:30 GMT</pubDate>
            <atom:updated>2026-11-15T08:05:30.984Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zVK35OeMpaWhs3YMf0TdvA.png" /></figure><p>What is LDEP Authentication?</p><p>LDEP authentication checks a user’s username and password against a directory server. such as OpenLDAP or Microsoft Active Directory, by sending a “bind” request over the LDAP protocol. It’s common for internal apps, VPN and infrastructure inside a company network. For web and SAAS apps that need single sign-on, SAML or OpenID Connect is usually the better fit.</p><p>LDEP(Lightweight Directory Access Protocol) is a widely user open source protocol, which allows computer systems to access user directory information over network. LDAP provides a way to organize information (often user authentication) in a hierarchical manner and to access this information quickly.</p><p>LDEP authentication is process of verifying the identity of a user by checking a provided credentials (username and password) against the data store in a LDAP directory server. The directory server holds information about all authorized users in system and their attributes such as passwords, name and access privileges.</p><p>When user try to login in the system sends the user’s credential to directory server and server validate the information. if the information match what is stored in the directory, the user granted access, otherwise the authentication request is denied.</p><p>in this article:<br>1: Why is LDAP Authentication important?</p><p>2: LDEV vs Active Directory: What are difference?</p><p>3: How does LDEP Authentication works?</p><p>4: LDEP vs SAML and SSO: when to use which</p><h4>Why is LDEP Authentication Important?</h4><p>The following are some of he key benefits of using LDEP for authentication:</p><p><strong>Centralized management:</strong> with LDAP, user authentication information is stored in centralized location, making it easier to manage and update.</p><p><strong>Scalability:</strong> LDAP is designed to handle large volumes of user authentication data, making it an ideal solution for large organization with many user.</p><p><strong>Interoperability:</strong> LDAP is standard protocol and us suppoert by many different platform, making it easy to integrate with other system and application.</p><p><strong>Security:</strong> LDAP traffic can be encrypted with LDAPS (port 636) or StartTLS. Without ine of them, a simple bind sends the password in clear text, so always required encryption.</p><p><strong>Efficiency:</strong> LDAP is designed to be fast and efficient, making it well-suited for real-time authentication requests.</p><h4>LDAP VS Active Directory: What are the Difference?</h4><p>Active Directory is directory service created by Microsoft for use in window-based network. It provides centralized management of resources, including users, computers, and othere network devices, and is designed to make adminsitration and management of large, complex enterprise network easier.</p><p>LDAP and Active Directory are both directory, because LDAP is a protocol and Active Directory is a directory product that supports LDAP. Application often use LDAP to talk to Active Directory.</p><p>The comparison is little uneven, because LDEP is protocol and active directory is a directory product that support LDAP. Applicaions often use LDAP to tak to active directory.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/899/1*Fr1WVGMTPkk5bT6jxj-a6Q.png" /></figure><p>To summarize, LDEP is basic directory protocol that is often used for authentication, while Active Directory is comprehansive directory that is well-suited for large, complex enterprise networks. The choice between the two will depend on specific requirements of the organization. LDAP is also opten compared with SAML: LDAP lets applicaiton look up and verify user against a directory, usaually inside a corporate network while SAML pasess signed authenticaion assertion from an identity provider to web application for single sign-on. Many organization use both togathere.</p><p>How Does LDAP Authentication work?</p><p>LDAP authentication typically works as follows:</p><p>1: The user provides their credentials (username and password) to the system.</p><p>2: The system sends a bind request to the LDAP server, containing the user’s credentials.</p><p>3: The LDAP server checks the user’s credentials against the data stored in its directory.</p><p>4: If the credentials match, the server send a success massage to the system, indicatind that the user has been authenticated.</p><p>5: The system grants the the user acces to the requested resources.</p><p>6: If the credentils do not match, the server sends a failure message of the system, indicating that the user has been autehenticated.</p><p>7: The system denies the user access to the request resource.</p><p>Use LdAP or StartTLS so the credentials in the bind request are encrypted between the application and directory server, and verify the server’s certificate. Many directories are deployed with replicas for the availablity, so aoolication can keep authenticating users if one server is down.</p><p>LDAP Vs SAML and SSO: When to user which</p><p>LDAP and SAML both deal with user identiry, but they solve different problem. LDAP lets an applicaion check a password against a directory. SAML and its newer conterpart OpenID Connect (OIDC), let an idenitty provider sign a user in and send the applicaion a signed assertion or token, which is how single sign-on (SSO) works on web.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/881/1*SJPub45XJ0WrLlk_wu2LYQ.png" /></figure><p>Use LDAP when an internal system, usch as server, network deivce or old on-premises app, needs to check credentials against your owen directory. Use SAML or OIDC when you build a web or SaaS app, expecially on that sell to companies: their IT teams expect to connect their identity provider, keep MFA and password under their control, and never hand your app their users’ password. Many organization run both: Active Directory as the directory, with an identity providers such as Microsoft Entra ID, ADFS or Okta in front of it for SSO.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d43304ba9a09" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Production-ready third-party JWT token management for Spring Boot microservices]]></title>
            <link>https://mirfanarshad.medium.com/production-ready-third-party-jwt-token-management-for-spring-boot-microservices-302ccc5f059b?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/302ccc5f059b</guid>
            <category><![CDATA[microservices]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[jwt-authentication]]></category>
            <category><![CDATA[redis]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Sun, 08 Nov 2026 19:28:26 GMT</pubDate>
            <atom:updated>2026-11-08T19:28:26.212Z</atom:updated>
            <content:encoded><![CDATA[<h3>How to Manage Third-Party JWT Tokens in Spring Boot Microservices</h3><p><strong>A practical approach to caching, sharing, refreshing, and reusing JWT tokens across multiple microservices using Spring Boot, WebClient, and Redis.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/972/1*wrfCw5WrmJXKcfchSHydNw.png" /></figure><h3>Introduction</h3><p>When building enterprise applications, integrating with third-party platforms is a common requirement. Whether you’re connecting to a payment gateway, banking platform, document management system, or another external service, authentication is usually one of the first things you need to handle.</p><p>Most modern platforms use JWT (JSON Web Token) or OAuth-based authentication. You send an authentication request, receive an access token, and include that token in subsequent API requests.</p><p>Sounds simple, right?</p><p>The challenge starts when your application grows.</p><p>Imagine having multiple Spring Boot microservices communicating with the same third-party platform. Each service needs a valid access token before it can make an API request.</p><p>Should every service request a new token whenever it needs to call an external API?</p><p>Should each service maintain its own token?</p><p>What happens when the token expires while multiple requests are being processed?</p><p>And what if the third party suddenly returns HTTP 401?</p><p>These are not just authentication questions. They are architectural concerns that can affect performance, scalability, reliability, and maintainability.</p><p>In this article, we’ll explore how to build a reusable JWT token management solution using Spring Boot, WebClient, and Redis.</p><h3>1. Understanding the problem</h3><p>Let’s consider a typical microservices architecture.</p><p>We have three services:</p><ul><li>Customer Service</li><li>Payment Service</li><li>Document Service</li></ul><p>All three services communicate with the same third-party platform.</p><p>The third party exposes two types of endpoints:</p><ol><li>An authentication endpoint that generates a JWT.</li><li>Business endpoints that require the JWT in the Authorization header.</li></ol><p>The authentication response might look like this:</p><pre>{<br>  &quot;access_token&quot;: &quot;eyJhbGciOiJIUzI1NiJ9...&quot;,<br>  &quot;token_type&quot;: &quot;Bearer&quot;,<br>  &quot;expires_in&quot;: 3600<br>}</pre><p>The token is valid for 3,600 seconds, or one hour.</p><p>A typical API request looks like this:</p><pre>GET /api/customers/12345 HTTP/1.1<br>Host: api.thirdparty.com<br>Authorization: Bearer eyJhbGciOiJIUzI1NiJ9...</pre><p>The obvious approach is to authenticate first and then use the returned token.</p><p>However, if every microservice independently requests a token, several problems can arise:</p><ul><li>Unnecessary authentication requests.</li><li>Increased response times.</li><li>Additional load on the third-party authentication server.</li><li>Duplicate token management logic.</li><li>Inconsistent token expiration handling.</li><li>Potential authentication bottlenecks during high traffic.</li></ul><p>We need a better approach.</p><h3>2. The proposed architecture</h3><p>Instead of allowing every business service to manage authentication independently, we introduce a centralized token management mechanism.</p><p>The architecture consists of the following components:</p><p>ComponentResponsibilityToken ProviderCommunicates with the third-party authentication APIToken ManagerManages token acquisition, expiration, and renewalRedisStores and shares the JWT across microservicesDistributed LockPrevents simultaneous token generationWebClient FilterAutomatically attaches the JWT to outgoing requestsAPI ClientProvides reusable methods for third-party API communication</p><p>The important point is that token management becomes an infrastructure concern rather than a business-service responsibility.</p><p>Each microservice can use the same integration library and Redis instance.</p><p>This keeps authentication logic consistent across the application.</p><h3>3. Why use Redis for token management?</h3><p>For a single application instance, an in-memory cache might be sufficient.</p><p>But consider a production environment where multiple microservice instances are running.</p><p>If every instance maintains its own token, you could end up with multiple authentication requests for the same third-party integration.</p><p>Redis solves this by providing a shared cache.</p><p>For example:</p><pre>Customer Service ─────┐<br>                      │<br>Payment Service ──────┼──── Redis<br>                      │      |<br>Document Service ─────┘      |<br>                             |<br>                        Shared JWT<br>                             |<br>                       Third-Party API</pre><p>Now all services can access the same cached token.</p><p>Redis also provides TTL (Time To Live), which allows us to configure how long a cached token should remain available.</p><p>One important consideration: this shared-token approach assumes the third party issues tokens that can be used by all consuming services under the same client, audience, tenant, and scope.</p><p>If those permissions differ, maintain separate cache entries.</p><h3>4. Setting up the Spring Boot project</h3><p>We’ll use:</p><ul><li>Java 17 or later.</li><li>Spring Boot 3.x.</li><li>Spring WebFlux WebClient.</li><li>Spring Data Redis Reactive.</li><li>Redis.</li><li>Reactor.</li></ul><p>Add the following dependencies:</p><pre>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-webflux&lt;/artifactId&gt;<br>    &lt;/dependency&gt;</pre><pre>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-starter-data-redis-reactive&lt;/artifactId&gt;<br>    &lt;/dependency&gt;</pre><pre>    &lt;dependency&gt;<br>        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>        &lt;artifactId&gt;spring-boot-configuration-processor&lt;/artifactId&gt;<br>        &lt;optional&gt;true&lt;/optional&gt;<br>    &lt;/dependency&gt;</pre><pre>&lt;/dependencies&gt;</pre><p>Spring WebClient provides a non-blocking HTTP client, while Reactive Redis allows us to interact with Redis without blocking application threads.</p><p>You can also use WebClient in a traditional Spring MVC application.</p><h3>5. Configure third-party authentication</h3><p>First, let’s define the configuration.</p><pre>third-party:<br>  api:<br>    base-url: https://api.thirdparty.com<br>    auth-url: https://api.thirdparty.com/authenticate</pre><pre>    client-id: ${THIRD_PARTY_CLIENT_ID}<br>    client-secret: ${THIRD_PARTY_CLIENT_SECRET}</pre><pre>    token-cache-key: thirdparty:uat:client-a:token<br>    lock-key: thirdparty:uat:client-a:token:lock</pre><pre>    expiry-skew-seconds: 60<br>    lock-ttl-seconds: 30<br>    lock-wait-seconds: 15</pre><pre>    connect-timeout-seconds: 5<br>    response-timeout-seconds: 10</pre><p>Credentials should come from environment variables or a secrets manager, not directly from source code.</p><p>Next, create a configuration properties class:</p><pre>@ConfigurationProperties(prefix = &quot;third-party.api&quot;)<br>public record ThirdPartyProperties(<br>    String baseUrl,<br>    String authUrl,<br>    String clientId,<br>    String clientSecret,<br>    String tokenCacheKey,<br>    String lockKey,<br>    long expirySkewSeconds,<br>    long lockTtlSeconds,<br>    long lockWaitSeconds,<br>    int connectTimeoutSeconds,<br>    int responseTimeoutSeconds<br>) {}</pre><p>For this example, we’ll assume the third-party authentication API accepts a JSON request containing a client ID and client secret.</p><p>The actual request format depends on the provider.</p><h3>6. Create the authentication provider</h3><p>The authentication provider has one responsibility: obtain a new access token.</p><p>It should not know anything about Redis, caching, or business API requests.</p><pre>public record ThirdPartyAuthRequest(<br>    String clientId,<br>    String clientSecret<br>) {}</pre><p>The response DTO:</p><pre>@JsonIgnoreProperties(ignoreUnknown = true)<br>public record ThirdPartyAuthResponse(</pre><pre>    @JsonProperty(&quot;access_token&quot;)<br>    String accessToken,</pre><pre>    @JsonProperty(&quot;token_type&quot;)<br>    String tokenType,</pre><pre>    @JsonProperty(&quot;expires_in&quot;)<br>    long expiresIn</pre><pre>) {}</pre><p>Now implement the provider:</p><pre>@Service<br>@RequiredArgsConstructor<br>public class ThirdPartyTokenProvider {</pre><pre>    private final WebClient authWebClient;<br>    private final ThirdPartyProperties properties;</pre><pre>    public Mono&lt;ThirdPartyAuthResponse&gt; generateToken() {</pre><pre>        var request = new ThirdPartyAuthRequest(<br>            properties.clientId(),<br>            properties.clientSecret()<br>        );</pre><pre>        return authWebClient.post()<br>            .uri(properties.authUrl())<br>            .contentType(MediaType.APPLICATION_JSON)<br>            .bodyValue(request)<br>            .retrieve()<br>            .bodyToMono(ThirdPartyAuthResponse.class)<br>            .timeout(Duration.ofSeconds(<br>                properties.responseTimeoutSeconds()<br>            ))<br>            .flatMap(response -&gt; {</pre><pre>                if (response.accessToken() == null<br>                        || response.accessToken().isBlank()<br>                        || response.expiresIn() &lt;= 0) {</pre><pre>                    return Mono.error(<br>                        new IllegalStateException(<br>                            &quot;Invalid authentication response&quot;<br>                        )<br>                    );<br>                }</pre><pre>                return Mono.just(response);<br>            });<br>    }<br>}</pre><p>Notice that this class only handles authentication.</p><p>That separation makes it easier to change the third-party authentication mechanism without modifying the token cache or business services.</p><h3>7. Implement the token manager</h3><p>This is where the actual token lifecycle is managed.</p><p>The Token Manager should:</p><ol><li>Check Redis for an existing token.</li><li>Verify that the token has not expired.</li><li>Return the existing token if valid.</li><li>Obtain a new token if necessary.</li><li>Save the new token in Redis with an appropriate TTL.</li></ol><p>We also need to consider a small but important detail: token expiration.</p><p>If the third party says a token expires in 60 minutes, we shouldn’t wait until the exact expiration time to replace it.</p><p>Instead, introduce an expiry buffer.</p><p>For example, if the token expires in 3,600 seconds and our buffer is 60 seconds, we consider it unavailable for reuse after 3,540 seconds.</p><p>This reduces the chance of sending an almost-expired token.</p><p>A Redis cache entry can be represented as:</p><pre>public record TokenCacheEntry(<br>    String accessToken,<br>    long expiresAtEpochMillis<br>) {}</pre><p>The Token Manager then reads the cache and checks validity.</p><pre>private boolean isValid(TokenCacheEntry entry) {</pre><pre>    long safeExpiry =<br>        entry.expiresAtEpochMillis()<br>            - expirySkewSeconds * 1000;</pre><pre>    return System.currentTimeMillis() &lt; safeExpiry;<br>}</pre><p>If the token is valid, return it.</p><p>If not, generate a new token and store it with a Redis TTL.</p><p>The token manager is also responsible for coordinating concurrent refresh operations, which brings us to the next challenge.</p><h3>8. Prevent duplicate token generation with distributed locking</h3><p>Imagine the cached token expires and 100 requests arrive at almost the same time.</p><p>Without synchronization, all 100 requests might discover that the token is expired and attempt to authenticate.</p><p>This creates unnecessary traffic and can overload the third-party authentication endpoint.</p><p>A regular Java synchronized block does not solve this problem across multiple microservice instances because each instance runs in a separate JVM.</p><p>We need distributed synchronization.</p><p>Redis provides a useful mechanism through:</p><pre>redis.opsForValue().setIfAbsent(<br>    lockKey,<br>    uniqueOwnerId,<br>    Duration.ofSeconds(30)<br>);</pre><p>This operation is atomic.</p><p>Only one instance can successfully acquire the lock.</p><p>The remaining instances wait until the token becomes available in Redis.</p><p>The process looks like this:</p><ol><li>Service A requests a token.</li><li>Service A acquires the Redis lock.</li><li>Services B, C, and D fail to acquire the lock.</li><li>Service A requests a new JWT.</li><li>Service A stores the JWT in Redis.</li><li>Service A releases the lock.</li><li>Other services retrieve the newly cached token.</li></ol><p>The result is one authentication request instead of four.</p><p>There are two important implementation details:</p><ul><li>Use a unique lock-owner ID and release the lock only if the owner matches.</li><li>Ensure the lock TTL exceeds the maximum authentication request duration.</li></ul><p>For stronger production guarantees, use lock renewal or fencing if authentication can exceed the configured TTL.</p><h3>9. Automatically attach JWT using WebClient filters</h3><p>Now that token acquisition and caching are handled, we can simplify our business API calls.</p><p>We don’t want developers to manually retrieve the token and add the Authorization header in every service.</p><p>Spring WebClient provides ExchangeFilterFunction, which is useful for handling common HTTP request behavior.</p><p>We can create an authentication filter that automatically:</p><ul><li>Retrieves the JWT from the Token Manager.</li><li>Adds the Bearer Authorization header.</li><li>Sends the request to the third party.</li></ul><p>Example:</p><pre>@Component<br>@RequiredArgsConstructor<br>public class ThirdPartyAuthFilter<br>        implements ExchangeFilterFunction {</pre><pre>    private final ThirdPartyTokenManager tokenManager;</pre><pre>    @Override<br>    public Mono&lt;ClientResponse&gt; filter(<br>            ClientRequest request,<br>            ExchangeFunction next) {</pre><pre>        return tokenManager.getAccessToken()<br>            .flatMap(token -&gt; {</pre><pre>                ClientRequest authenticatedRequest =<br>                    ClientRequest.from(request)<br>                        .headers(headers -&gt;<br>                            headers.setBearerAuth(token)<br>                        )<br>                        .build();</pre><pre>                return next.exchange(authenticatedRequest);<br>            });<br>    }<br>}</pre><p>Register the filter with the business API WebClient.</p><pre>@Bean<br>WebClient thirdPartyWebClient(<br>        ThirdPartyProperties properties,<br>        ThirdPartyAuthFilter authFilter) {</pre><pre>    return WebClient.builder()<br>        .baseUrl(properties.baseUrl())<br>        .filter(authFilter)<br>        .build();<br>}</pre><p>Keep the authentication WebClient separate so that authentication requests don’t recursively trigger the same JWT filter.</p><p>Now every business request automatically receives the required token.</p><h3>10. Handle HTTP 401 and automatically retry</h3><p>Token expiration isn’t always predictable.</p><p>A third party might revoke a token before its expected expiration or invalidate it due to changes in authentication policies.</p><p>Therefore, our integration should handle HTTP 401 responses.</p><p>A sensible recovery process is:</p><ol><li>Send the original request.</li><li>Receive HTTP 401.</li><li>Release the original response body.</li><li>Invalidate the rejected token in Redis, but only if it is still the current cached token.</li><li>Obtain a valid token.</li><li>Retry the original request once.</li><li>Propagate the error if the retry also fails.</li></ol><p>There is an important concurrency consideration here.</p><p>Suppose Service A sends a request using JWT-1. Meanwhile, Service B refreshes the token and stores JWT-2 in Redis.</p><p>Service A then receives a delayed 401 for JWT-1.</p><p>If Service A simply deletes the cached token, it will accidentally remove JWT-2.</p><p>To prevent this, use conditional invalidation with a Redis Lua script.</p><pre>local value = redis.call(&#39;get&#39;, KEYS[1])</pre><pre>if value then<br>    local token = cjson.decode(value)</pre><pre>    if token.accessToken == ARGV[1] then<br>        return redis.call(&#39;del&#39;, KEYS[1])<br>    end<br>end</pre><pre>return 0</pre><p>This only removes the token if Redis still contains the rejected JWT.</p><p>For automatic retries, also consider request idempotency.</p><p>GET, HEAD, and OPTIONS are generally suitable for automatic retry. POST, PUT, PATCH, and DELETE should only be retried when the operation is safe to repeat or protected by an idempotency mechanism.</p><p>Streaming request bodies also need special handling because they might not be replayable.</p><p>Never retry indefinitely.</p><h3>11. Build a reusable third-party API client</h3><p>At this point, authentication has become transparent to business services.</p><p>We can introduce a reusable API client.</p><pre>@Service<br>@RequiredArgsConstructor<br>public class ThirdPartyApiClient {</pre><pre>    private final WebClient thirdPartyWebClient;</pre><pre>    public &lt;T&gt; Mono&lt;T&gt; get(<br>            String endpoint,<br>            Class&lt;T&gt; responseType) {</pre><pre>        return thirdPartyWebClient.get()<br>            .uri(endpoint)<br>            .retrieve()<br>            .bodyToMono(responseType);<br>    }</pre><pre>    public &lt;R&gt; Mono&lt;R&gt; post(<br>            String endpoint,<br>            Object request,<br>            Class&lt;R&gt; responseType) {</pre><pre>        return thirdPartyWebClient.post()<br>            .uri(endpoint)<br>            .bodyValue(request)<br>            .retrieve()<br>            .bodyToMono(responseType);<br>    }<br>}</pre><p>A business service can now look like this:</p><pre>@Service<br>@RequiredArgsConstructor<br>public class PaymentService {</pre><pre>    private final ThirdPartyApiClient apiClient;</pre><pre>    public Mono&lt;PaymentResponse&gt; getPayment(<br>            String paymentId) {</pre><pre>        return apiClient.get(<br>            &quot;/payments/&quot; + paymentId,<br>            PaymentResponse.class<br>        );<br>    }<br>}</pre><p>The Payment Service doesn’t need to know how authentication works.</p><p>It simply calls the API.</p><p>That’s the separation of responsibilities we want in a maintainable microservices architecture.</p><h3>12. Should we refresh tokens proactively?</h3><p>There are two common approaches.</p><p><strong>On-demand renewal</strong></p><p>The application obtains a new token only when an API request discovers that the cached token is missing or approaching expiration.</p><p>This is simple and avoids unnecessary authentication requests.</p><p><strong>Proactive renewal</strong></p><p>A scheduled process checks the token periodically and renews it before expiration.</p><p>For example:</p><ul><li>Token lifetime: 60 minutes.</li><li>Expiry buffer: 60 seconds.</li><li>Refresh check: every 30 seconds.</li></ul><p>The scheduler should use the same Token Manager and distributed lock.</p><p>This means multiple microservice instances can run the scheduled check without generating duplicate tokens.</p><p>For most integrations, I recommend starting with on-demand renewal. Introduce proactive renewal if your business requirements need a continuously warm token cache.</p><h3>13. Production considerations</h3><p>A working implementation is only part of the job. A production integration should also account for operational and security concerns.</p><p>AreaRecommendationToken storageShared Redis cacheToken expirationUse provider expiry and a safety bufferDistributed lockingAtomic Redis lock with unique ownershipAuthenticationSeparate authentication WebClientHTTP clientWebClient with connection and response timeoutsRetryBounded, with idempotency protectionSecretsEnvironment variables or a secrets managerRedis securityTLS, ACLs, and restricted network accessLoggingNever log JWTs or client secretsMonitoringTrack cache hits, refresh failures, and 401 responsesResilienceControlled failure handling and circuit breakers</p><p>You should also monitor Redis availability. If Redis is unavailable, a shared-token architecture should fail in a controlled way rather than causing every service to independently authenticate.</p><p>Useful metrics include:</p><ul><li>Token cache hits and misses.</li><li>Successful token refreshes.</li><li>Failed authentication attempts.</li><li>Distributed lock contention.</li><li>HTTP 401 responses.</li><li>Retry attempts.</li><li>Authentication endpoint response time.</li></ul><p>These metrics make it easier to identify authentication bottlenecks before they become production incidents.</p><h3>14. Testing the implementation</h3><p>Before deploying, test more than just successful authentication.</p><p>Here are the scenarios worth covering:</p><p>ScenarioExpected behaviorFirst API requestObtain and cache a JWTSubsequent requestReuse cached JWTMultiple services request simultaneouslyOne token generationToken approaches expirationObtain a replacementRedis cache is emptyAuthenticate againThird party returns 401Invalidate and retry eligible request onceOld JWT receives delayed 401Preserve newer cached JWTAuthentication endpoint unavailableReturn controlled errorRedis unavailableFail with controlled dependency errorRetry returns 401Propagate final errorNon-idempotent POST receives 401Do not retry automatically</p><p>For distributed locking, use integration tests with multiple application instances connected to the same Redis environment.</p><p>Unit tests alone cannot prove that your locking strategy works correctly across JVM boundaries.</p><h3>Conclusion</h3><p>JWT management is easy to overlook when integrating with third-party platforms. Initially, retrieving a token and adding it to an Authorization header might seem sufficient.</p><p>But as your application grows and multiple microservices start sharing the same integration, authentication becomes a cross-cutting concern that deserves its own design.</p><p>Using Spring Boot, WebClient, and Redis gives us a practical way to manage this responsibility.</p><p>The key is to separate token acquisition from token consumption, share the cached token where appropriate, coordinate refresh operations, and handle authentication failures consistently.</p><p>The result is a cleaner integration architecture with fewer unnecessary authentication requests, better resource utilization, and reusable infrastructure across microservices.</p><p><strong>Good microservice architecture isn’t just about making services independent. It’s also about managing shared concerns consistently.</strong></p><h3>Key takeaways</h3><ul><li>Don’t request a new JWT for every API call.</li><li>Use Redis when multiple services need to share a token.</li><li>Use distributed locking to prevent duplicate refresh requests.</li><li>Introduce an expiry buffer rather than waiting for exact expiration.</li><li>Use WebClient filters to centralize authentication.</li><li>Handle HTTP 401 with conditional invalidation and bounded retries.</li><li>Keep authentication logic separate from business logic.</li></ul><p><strong>Technologies:</strong> Java · Spring Boot · Spring WebFlux · WebClient · Redis · JWT · Microservices</p><p>#Spring Boot, #Java, #Microservices #Architecture, #JWT #Authentication, #Redis, #WebClient, #Software #Architecture</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=302ccc5f059b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot 3 EOL to Spring Boot 4: A Production Upgrade Playbook]]></title>
            <link>https://mirfanarshad.medium.com/spring-boot-3-eol-to-spring-boot-4-a-production-upgrade-playbook-35d5b542c88a?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/35d5b542c88a</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[fintech]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[java8]]></category>
            <category><![CDATA[spring-framework]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 08:02:57 GMT</pubDate>
            <atom:updated>2026-11-02T08:02:57.092Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*j7lftIujjqyOas9t" /></figure><p>It sits on the newer Spring generation, and Spring Boot 4.x builds on Spring Framework 7, which introduced a new framework generation with broad ecosystem upgrades. Spring Boot 4.1 also adds release train changes like Spring gRPC support, SSRF mitigation for HTTP clients, observability improvements, and upgraded dependencies.</p><p>That means upgrading is not just about changing this:</p><p>That means upgrading is not just about changing this:</p><pre>&lt;spring-boot.version&gt;2.x.x&lt;/spring-boot.version&gt;<br>&lt;spring-boot.version&gt;3.x.x&lt;/spring-boot.version&gt;</pre><p>to this:</p><pre>&lt;spring-boot.version&gt;4.1.x&lt;/spring-boot.version&gt;</pre><p>It is about checking whether your application, libraries, configuration, and platform assumptions still match the new ecosystem.</p><p>And if you are jumping from 2.x, this is not one migration.</p><p>It is two migrations wearing one version number.</p><p>Spring Boot 4 is not a routine version bump.</p><p>This migration touches platform baselines (Java/Jakarta/Servlet), dependency structure, test infrastructure, and JSON behavior — all at once.</p><p>If your services are still on Spring Boot 3.x, I wrote this as a practical, production-oriented playbook to move to Spring Boot 4 safely, with explicit attention to end-of-life (EOL) risk, CVE exposure, and Jackson 2 to Jackson 3 changes.</p><p>In this post, we’ll cover:</p><ul><li>What Spring Boot 3.x EOL means in practice and how CVE pressure changes</li><li>A phased migration strategy from Spring Boot 3.5 to 4.0</li><li>Hands-on code changes for starters, Jackson, tests, and security</li><li>Companion migrations for Spring Modulith 2.0 and Testcontainers 2.x</li><li>A production rollout checklist with CI/CD gates you can apply immediately</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/647/0*PllSUvylUuEKHiln" /></figure><p>Now let’s go through them like a real migration checklist.</p><h3>Why This Upgrade Is Time-Sensitive</h3><p>Spring Boot support is minor-line based.</p><p>From the <a href="https://spring.io/projects/spring-boot#support">official support table</a>, Spring Boot 3.5.x has OSS support through June 2026, while Spring Boot 4.0.x has OSS support through December 2026 (with longer <a href="https://github.com/spring-projects/spring-boot/wiki/Supported-Versions">enterprise support windows</a>).</p><p>What does that actually mean in practice?</p><ul><li>EOL does not mean your app stops running on that date.</li><li>EOL means you stop receiving community security and bug-fix patches for that line.</li><li>New vulnerabilities continue to be discovered after EOL, but fixes are not backported to unsupported lines.</li></ul><p>The real risk is not immediate outage — it’s rising security and compliance debt that compounds over time.</p><p>If your services also use Spring AI, the window is even tighter. Spring AI 1.x aligns to Spring Boot 3.5, while Spring AI 2.0 tracks Boot 4. That means platform migration and AI API migration timelines are coupled — plan for both.</p><h3>CVEs, Risk, and What to Watch</h3><p>A concrete example in 2026 came from Spring AI advisories:</p><ul><li><a href="https://spring.io/security/cve-2026-22729">CVE-2026–22729</a> — JSONPath injection</li><li><a href="https://spring.io/security/cve-2026-22730">CVE-2026–22730</a> — SQL injection</li></ul><p>Both affected Spring AI 1.0.x/1.1.x and were fixed in 1.0.4 and 1.1.3.</p><p>These are Spring AI vulnerabilities, not Spring Boot core CVEs. But for many teams, the platform decisions are coupled — Boot baseline plus AI stack move together.</p><p>This is exactly how lifecycle pressure appears in real systems: you can patch while your line is supported. After EOL, newly discovered issues may not receive OSS backports.</p><p>If your organization is still on 3.5 close to EOL, your risk model should assume more frequent scanner findings, harder remediation conversations, and tighter migration timelines under pressure.</p><h3>Migration Strategy: Three Phases, Not One Version Bump</h3><p>So how do we approach this? Not as “change one version and pray.”</p><p>A safer model is three phases:</p><ol><li>Stabilize on latest 3.5.x</li><li>Migrate to 4.0 with compatibility bridges</li><li>Converge to native 4.0 patterns and remove temporary bridges</li></ol><p>This aligns with the <a href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide">official Spring Boot 4 migration guide</a>.</p><h3>End-to-end migration flow</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/481/0*L3E9NuIdXPn-Hlxz" /></figure><h3>Step 1: Baseline and Stabilize on Spring Boot 3.5.x</h3><p>Before we touch major versions, let’s create a factual inventory and get on the latest 3.5.x patch.</p><h3>Build your before-state inventory</h3><p>What do we need to capture?</p><ul><li>Java runtime versions in CI/CD and production</li><li>App server/container choices (Tomcat/Jetty/Undertow)</li><li>External BOMs and explicitly pinned versions (Spring Cloud, Security, Data, Kafka, vendor libs)</li><li>JSON customizations (custom serializers, modules, ObjectMapper wiring)</li><li>Test stack assumptions (@MockBean, MockMvc shortcuts, TestRestTemplate usage)</li><li>Build/package assumptions (fully executable jars, classic loader settings)</li></ul><pre># Maven<br>mvn -q -DskipTests dependency:tree &gt; dependency-tree.txt<br>mvn -q -DskipTests help:effective-pom &gt; effective-pom.xml<br><br># Gradle<br>./gradlew dependencies &gt; dependency-tree.txt<br>./gradlew projects &gt; projects.txt</pre><p>Capture this as your before-state artifact. We’ll compare it against the after-state once we’re on Boot 4.</p><h3>Move to latest 3.5.x</h3><p>The <a href="https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-4.0-Migration-Guide">official migration guide</a> explicitly recommends moving to latest 3.5.x before upgrading to 4.0.</p><p>Maven:</p><pre>&lt;parent&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;<br>  &lt;version&gt;3.5.x&lt;/version&gt;<br>&lt;/parent&gt;</pre><p>Gradle:</p><pre>plugins {<br>  id(&quot;org.springframework.boot&quot;) version &quot;3.5.x&quot;<br>}</pre><p>Why this matters:</p><ul><li>We get the latest fixes in the 3.5 line</li><li>We reduce the delta size when jumping to 4.0</li><li>We surface deprecations in a safer context</li></ul><h3>Remove 3.x deprecations aggressively</h3><p>Everything deprecated across 3.x should be considered a 4.0 removal candidate. Turn deprecation warnings into a tracked backlog and fix high-frequency and startup-path deprecations first.</p><h3>Step 2: Validate Platform Baselines for Boot 4</h3><p>Before we change the Boot version, let’s make sure our infrastructure can actually run Boot 4. It raises the floor on several platform requirements:</p><ul><li>Java 17+</li><li>Jakarta EE 11</li><li>Servlet 6.1</li><li>Spring Framework 7.x</li><li>Kotlin 2.2+ (if applicable)</li><li>GraalVM 25+ for native-image flows</li></ul><p>Common pitfall: teams upgrade Boot but not infra assumptions — container images, app servers, plugin versions — then discover breakage late in pre-prod. Validate your CI/CD images and deployment targets against these baselines before changing the Boot version.</p><h3>Step 3: Upgrade to Spring Boot 4</h3><p>Now we get to the actual version bump. This step covers starter model changes and removed features. Each change includes before/after code so you can apply it directly.</p><h3>Version bump and classic bridge</h3><p>Let’s start by updating the parent/BOM and plugin to 4.0.x. If your codebase is large, add the classic starter bridge first to keep the app booting while you converge.</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-classic&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>This reduces “too many unknowns at once” failures. Remove the classic bridge once you have migrated to focused starters.</p><h3>Rename starters to focused equivalents</h3><p>Boot 4 introduces a <a href="https://spring.io/blog/2025/10/28/modularizing-spring-boot/">new modular design</a> and prefers explicit, technology-specific starters over generic ones. The deprecated starter names still work, but should be migrated.</p><pre>&lt;!-- Before --&gt;<br>spring-boot-starter-web	                <br>spring-boot-starter-web-services	<br>spring-boot-starter-aop	               <br>spring-boot-starter-json	        <br>spring-boot-starter-oauth2-client	<br>spring-boot-starter-oauth2-resource-server	<br>spring-boot-starter-oauth2-authorization-server	<br>spring-security-test	<br><br>&lt;!-- After --&gt;<br>spring-boot-starter-webmvc<br>spring-boot-starter-webservices<br>spring-boot-starter-aspectj<br>spring-boot-starter-jackson<br>spring-boot-starter-security-oauth2-client<br>spring-boot-starter-security-oauth2-resource-server<br>spring-boot-starter-security-oauth2-authorization-server<br>spring-boot-starter-security-test<br>spring-boot-starter-restclient (Before implicit via classpath now explicit)<br>spring-boot-starter-webclient (implicit via classpath now explicit)<br>spring-boot-starter-flyway (implicit via classpath now explicit)<br>spring-boot-starter-liquibase (implicit via classpath now explicit)</pre><p>Every technology starter now also has a paired test starter (spring-boot-starter-&lt;technology&gt;-test) that brings spring-boot-starter-test transitively. You no longer need to declare spring-boot-starter-test directly — list the test starters for the technologies under test instead.</p><p>Before:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;<br>&lt;/dependency&gt; </pre><p>After:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-webmvc&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-aspectj&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>If you use RestClient, WebClient, Flyway, or Liquibase, add those starters explicitly — Boot 4 no longer auto-configures them from classpath presence alone:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-restclient&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-webclient&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-flyway&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>For tests, replace the bare spring-security-test dependency with the new Boot-managed starter:</p><pre>&lt;!-- Before --&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.security&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-security-test&lt;/artifactId&gt;<br>  &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><pre>&lt;!-- After --&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-security-test&lt;/artifactId&gt;<br>  &lt;scope&gt;test&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p>Why does this matter? Fewer accidental transitive dependencies, cleaner module graph, and better control over attack surface and startup footprint.</p><p>One thing to watch: “it compiles” but some infra auto-config is missing at runtime because starter coverage changed. Test application context startup explicitly.</p><h3>Replace Undertow with Tomcat or Jetty</h3><p>Boot 4 dropped Undertow support because Undertow does not yet implement Servlet 6.1.</p><p>Before:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;<br>  &lt;exclusions&gt;<br>    &lt;exclusion&gt;<br>      &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>      &lt;artifactId&gt;spring-boot-starter-tomcat&lt;/artifactId&gt;<br>    &lt;/exclusion&gt;<br>  &lt;/exclusions&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-undertow&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>After (Tomcat is the default, or switch to Jetty):</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-webmvc&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;!-- For Jetty instead of Tomcat:<br>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-starter-jetty&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>--&gt;</pre><p>Also remove any server.undertow.* properties from your configuration files.</p><h3>Remove fully executable jar launch scripts</h3><p>Boot 4 also removed embedded init.d-style launch scripts. If you’re using the &lt;executable&gt;true&lt;/executable&gt; flag, that needs to go.</p><p>Before:</p><pre>&lt;plugin&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;<br>  &lt;configuration&gt;<br>    &lt;executable&gt;true&lt;/executable&gt;<br>  &lt;/configuration&gt;<br>&lt;/plugin&gt;</pre><p>After:</p><pre>&lt;plugin&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;<br>&lt;/plugin&gt;</pre><p>Switch to systemd or container-based process management instead.</p><h3>Package relocations</h3><p>This one is subtle. Boot 4 relocated several framework classes to new packages. They compile fine on 3.5 but break silently after upgrading if you don’t update the imports.</p><pre>EntityScan	<br>&lt;!-- Before --&gt;<br>org.springframework.boot.autoconfigure.domain<br>&lt;!-- After--&gt;<br>org.springframework.boot.persistence.autoconfigure</pre><pre>BootstrapRegistry<br>&lt;!-- Before --&gt;	<br>org.springframework.boot<br>&lt;!-- After--&gt;	<br>org.springframework.boot.bootstrap</pre><pre>BootstrapContext<br>&lt;!-- Before --&gt;		<br>org.springframework.boot<br>&lt;!-- After--&gt;		<br>org.springframework.boot.bootstrap</pre><pre>EnvironmentPostProcessor<br>&lt;!-- Before --&gt;	<br>org.springframework.boot.env<br>&lt;!-- After--&gt;		<br>org.springframework.boot</pre><pre>grep -rn &quot;import org.springframework.boot.autoconfigure.domain.EntityScan&quot; src/<br>grep -rn &quot;import org.springframework.boot.BootstrapRegistry&quot; src/<br>grep -rn &quot;import org.springframework.boot.BootstrapContext&quot; src/<br>grep -rn &quot;import org.springframework.boot.env.EnvironmentPostProcessor&quot; src/</pre><h3>Configuration defaults that changed</h3><p>Two defaults flipped in Boot 4 that can catch you off guard in production:</p><ul><li>Health probes are now enabled by default. Kubernetes liveness (/livez) and readiness (/readyz) endpoints are active out of the box. If you relied on them being off, review your probe configuration.</li><li>DevTools live reload is now disabled by default. If your team uses DevTools live reload in development, you’ll need to enable it explicitly:</li></ul><pre>spring.devtools.livereload.enabled=true</pre><p>A few other things were removed: Spock integration is gone from Boot (Spock doesn’t yet support Groovy 5), Pulsar Reactive auto-config is gone, and direct support for Spring Session Hazelcast and Spring Session MongoDB has moved to those projects’ own teams. Run these searches to catch any remaining references in your codebase:</p><pre>grep -rn &quot;undertow&quot; build.gradle* pom.xml src/main/resources/<br>grep -rn &quot;&lt;executable&gt;true&lt;/executable&gt;&quot; pom.xml<br>grep -rn &quot;spring-boot-starter-web\&quot;&quot; build.gradle* pom.xml<br>grep -rn &quot;spring-boot-starter-aop\&quot;&quot; build.gradle* pom.xml</pre><h3>Step 4: Migrate Jackson 2 to Jackson 3</h3><p>In my experience, this is the highest-risk part of the upgrade. Spring Boot 4 defaults to Jackson 3, and the changes go well beyond import renames — serialization behavior and property namespaces changed too.</p><p>Let’s walk through each layer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/661/0*4PhUyuDw-XV5Wee8" /></figure><h3>Update imports</h3><p>Jackson 3 moved most packages from com.fasterxml.jackson to tools.jackson. The exception is jackson-annotations, which stays at com.fasterxml.jackson.annotation.</p><p>Before:</p><pre>import com.fasterxml.jackson.databind.ObjectMapper;<br>import com.fasterxml.jackson.databind.SerializationFeature;<br>import com.fasterxml.jackson.core.JsonProcessingException;<br>import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;</pre><p>After:</p><pre>import tools.jackson.databind.ObjectMapper;<br>import tools.jackson.databind.SerializationFeature;<br>import tools.jackson.core.JsonProcessingException;<br>import tools.jackson.datatype.jsr310.JavaTimeModule;</pre><p>Important: imports from com.fasterxml.jackson.annotation (like @JsonProperty, @JsonIgnore, @JsonCreator) do not change. Leave those as they are.</p><pre>grep -rn &quot;import com.fasterxml.jackson&quot; src/ | grep -v &quot;annotation&quot;</pre><h3>Rename Boot’s Jackson integration classes</h3><p>Beyond the Jackson library imports, Boot 4 also renamed its own integration classes. These are the ones we use when customizing ObjectMapper behavior or writing custom serializers in Spring.</p><pre>&lt;!-- Before --&gt;<br>Jackson2ObjectMapperBuilderCustomizer <br>&lt;!-- After --&gt;<br>JsonMapperBuilderCustomizer<br><br>&lt;!-- Before --&gt;<br>@JsonComponent<br>&lt;!- After --&gt;<br>@JacksonComponent<br><br>&lt;!-- Before --&gt;<br>@JsonMixin<br>&lt;!- After --&gt;<br>@JacksonMixin<br><br>&lt;!-- Before --&gt;<br>JsonObjectSerializer<br>&lt;!-- After -- &gt;<br>ObjectValueSerializer<br><br>&lt;!-- Before --&gt;<br>JsonObjectDeserializer<br>&lt;!-- After -- &gt;<br>ObjectValueDeserializer </pre><p>The pattern is consistent: anywhere Boot’s Jackson integration used a Json prefix, it’s now Jackson (for annotations and supporting classes) or the type was renamed for clarity. Apply the same import-and-extends rename to all four classes — the example below shows one of them.</p><p>Before:</p><pre>import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;<br>import org.springframework.boot.jackson.JsonComponent;<br>import org.springframework.boot.jackson.JsonObjectSerializer;</pre><pre>@JsonComponent<br>public class MoneySerializer extends JsonObjectSerializer&lt;Money&gt; {<br>    // ...<br>}</pre><p>After:</p><pre>import org.springframework.boot.jackson.JsonMapperBuilderCustomizer;<br>import org.springframework.boot.jackson.JacksonComponent;<br>import org.springframework.boot.jackson.ObjectValueSerializer;</pre><pre>@JacksonComponent<br>public class MoneySerializer extends ObjectValueSerializer&lt;Money&gt; {<br>    // ...<br>}</pre><pre>grep -rn &quot;Jackson2ObjectMapperBuilderCustomizer\|@JsonComponent\|JsonObjectSerializer\|JsonObjectDeserializer&quot; src/</pre><h3>Update dependency coordinates</h3><p>If you declare Jackson dependencies explicitly (outside Boot’s managed BOM), we need to update the group IDs too.</p><p>Before (Maven):</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;com.fasterxml.jackson.core&lt;/groupId&gt;<br>  &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;com.fasterxml.jackson.datatype&lt;/groupId&gt;<br>  &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;<br>&lt;/dependency&gt; </pre><p>After (Maven):</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;tools.jackson.core&lt;/groupId&gt;<br>  &lt;artifactId&gt;jackson-databind&lt;/artifactId&gt;<br>&lt;/dependency&gt;<br>&lt;dependency&gt;<br>  &lt;groupId&gt;tools.jackson.datatype&lt;/groupId&gt;<br>  &lt;artifactId&gt;jackson-datatype-jsr310&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>Before (Gradle):</p><pre>implementation(&quot;com.fasterxml.jackson.core:jackson-databind&quot;)<br>implementation(&quot;com.fasterxml.jackson.datatype:jackson-datatype-jsr310&quot;)</pre><p>After (Gradle):</p><pre>implementation(&quot;tools.jackson.core:jackson-databind&quot;)<br>implementation(&quot;tools.jackson.datatype:jackson-datatype-jsr310&quot;)</pre><p>If Boot BOM manages these for you, remove explicit coordinates and let the BOM resolve them.</p><h3>Migrate property namespaces</h3><p>Several application.properties / application.yml keys moved. The most important change: JSON-specific spring.jackson.read.* and spring.jackson.write.* properties moved beneath spring.jackson.json.read.* and spring.jackson.json.write.*.</p><p>spring.jackson.parser.* properties were also replaced with spring.jackson.json.read.* where a Jackson 2 JsonParser.Feature has an equivalent Jackson 3 JsonReadFeature. For features without a JsonReadFeature equivalent, use a JsonMapperBuilderCustomizer programmatically.</p><p>Before (application.properties):</p><pre>spring.jackson.write.write-dates-as-timestamps=false<br>spring.jackson.read.fail-on-unknown-properties=true<br>spring.jackson.parser.allow-comments=true</pre><p>After:</p><pre>spring.jackson.json.write.write-dates-as-timestamps=false<br>spring.jackson.json.read.fail-on-unknown-properties=true<br>spring.jackson.json.read.allow-comments=true</pre><p>The equivalent in application.yml:</p><pre>spring:<br>  jackson:<br>    json:<br>      write:<br>        write-dates-as-timestamps: false<br>      read:<br>        fail-on-unknown-properties: true<br>        allow-comments: true</pre><h3>Use the properties migrator to catch the rest</h3><p>Boot 4 ships a runtime helper that analyzes your environment and reports any properties that need attention. Add it temporarily as a runtime dependency:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-properties-migrator&lt;/artifactId&gt;<br>  &lt;scope&gt;runtime&lt;/scope&gt;<br>&lt;/dependency&gt;</pre><p>Or Gradle:</p><pre>runtimeOnly(&quot;org.springframework.boot:spring-boot-properties-migrator&quot;)</pre><p>It will not only print diagnostics at startup, but temporarily migrate properties at runtime. Remove it once you’ve fixed every reported key.</p><pre>grep -rn &quot;spring.jackson\.&quot; src/main/resources/</pre><h3>Behavioral changes to expect</h3><p>What about the actual JSON output? From the <a href="https://github.com/FasterXML/jackson/wiki/Jackson-Release-3.0">Jackson 3 release notes</a>, key changes include:</p><ul><li>Major API renames/removals from deprecated 2.x APIs</li><li>Different defaults for several serialization/deserialization features</li><li>Java 17 baseline</li><li>Built-in support for former Java 8 datatype modules in databind</li></ul><p>Do not assume JSON payloads remain bit-identical by default. For more context, see the Spring team’s <a href="https://spring.io/blog/2025/10/07/introducing-jackson-3-support-in-spring">introduction to Jackson 3 support</a>.</p><h3>Compatibility levers</h3><p>What if we can’t move everything at once? Boot 4 provides two migration aids.</p><p>Jackson-2-like defaults flag (the auto-configured JsonMapper will use defaults aligned with Jackson 2 in Boot 3.x):</p><p>What if we can’t move everything at once? Boot 4 provides two migration aids.</p><p>Jackson-2-like defaults flag (the auto-configured JsonMapper will use defaults aligned with Jackson 2 in Boot 3.x):</p><pre>spring.jackson.use-jackson2-defaults=true</pre><p>For more invasive needs, the spring-boot-jackson2 module ships a Jackson 2 ObjectMapper you can use alongside Boot’s auto-configured Jackson 3 mapper. It’s deprecated on arrival — intended as a stop-gap, not a permanent setup:</p><pre>&lt;dependency&gt;<br>  &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>  &lt;artifactId&gt;spring-boot-jackson2&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><p>When using spring-boot-jackson2, configure the Jackson 2 mapper under spring.jackson2.* — these keys are equivalent to the spring.jackson.* properties from Boot 3.5.</p><h3>Module auto-registration</h3><p>Boot 4 detects and registers all Jackson modules found on classpath by default. If this pulls in unexpected behavior:</p><pre>spring.jackson.find-and-add-modules=false</pre><p>Prefer explicit module hygiene before reaching for this flag.</p><h3>Contract testing approach</h3><p>This is where we protect ourselves. Use golden payload fixtures and compare old/new behavior for:</p><ul><li>date/time serialization format</li><li>enum serialization/deserialization behavior</li><li>unknown property handling</li><li>polymorphic type resolution</li><li>null/default handling</li></ul><p>Practical rollout:</p><ol><li>Enable spring.jackson.use-jackson2-defaults=true</li><li>Make tests pass and deploy safely</li><li>Remove compatibility defaults incrementally</li><li>Keep each behavior change behind tests and changelog notes</li></ol><h3>Step 5: Migrate Tests and Security Configuration</h3><p>From the migration guide and <a href="https://github.com/spring-projects/spring-framework/wiki/Spring-Framework-7.0-Release-Notes">Spring Framework 7 release notes</a>, test behavior shifted in ways many teams miss until late in the migration. Let’s go through the ones that will affect most codebases.</p><h3>Replace @MockBean and @SpyBean</h3><p>Boot 4 removed @MockBean and @SpyBean from the framework’s test support. The replacement is straightforward — we switch to @MockitoBean and @MockitoSpyBean.</p><p>Before:</p><pre>import org.springframework.boot.test.mock.mockito.MockBean;<br>import org.springframework.boot.test.mock.mockito.SpyBean;</pre><pre>@SpringBootTest<br>class OrderServiceTest {</pre><pre>    @MockBean<br>    private PaymentGateway paymentGateway;</pre><pre>    @SpyBean<br>    private NotificationService notificationService;<br>}</pre><p>After:</p><pre>import org.springframework.test.context.bean.override.mockito.MockitoBean;<br>import org.springframework.test.context.bean.override.mockito.MockitoSpyBean;</pre><pre>@SpringBootTest<br>class OrderServiceTest {</pre><pre>    @MockitoBean<br>    private PaymentGateway paymentGateway;</pre><pre>    @MockitoSpyBean<br>    private NotificationService notificationService;<br>}</pre><pre>grep -rn &quot;@MockBean\|@SpyBean&quot; src/test/</pre><h3>Update @SpringBootTest and test client usage</h3><p>Here’s one that tripped me up: @SpringBootTest no longer auto-configures MockMvc. We need to add @AutoConfigureMockMvc explicitly.</p><p>Before:</p><pre>@SpringBootTest<br>class OrderControllerTest {</pre><pre>    @Autowired<br>    private MockMvc mockMvc;<br>}</pre><p>After:</p><pre>import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;</pre><pre>@SpringBootTest<br>@AutoConfigureMockMvc<br>class OrderControllerTest {</pre><pre>    @Autowired<br>    private MockMvc mockMvc;<br>}</pre><p>TestRestTemplate is replaced by RestTestClient with its own auto-configuration annotation.</p><p>Before:</p><pre>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)<br>class OrderApiTest {</pre><pre>    @Autowired<br>    private TestRestTemplate restTemplate;<br>}</pre><p>After:</p><pre>import org.springframework.boot.test.autoconfigure.web.client.AutoConfigureRestTestClient;<br>import org.springframework.boot.test.web.client.RestTestClient;</pre><pre>@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)<br>@AutoConfigureRestTestClient<br>class OrderApiTest {</pre><pre>    @Autowired<br>    private RestTestClient restTestClient;<br>}</pre><p>@WebMvcTest moved to a new package:</p><pre>// Before<br>import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;</pre><pre>// After<br>import org.springframework.boot.webmvc.test.autoconfigure.WebMvcTest;</pre><p>And if you use declarative HTTP clients, HttpServiceProxyFactory is replaced by the @ImportHttpServices annotation. The result? Much less boilerplate:</p><p>Before:</p><pre>import org.springframework.web.service.invoker.HttpServiceProxyFactory;</pre><pre>@Bean<br>InventoryClient inventoryClient(RestClient.Builder builder) {<br>    var factory = HttpServiceProxyFactory<br>        .builderFor(RestClientAdapter.create(builder.build()))<br>        .build();<br>    return factory.createClient(InventoryClient.class);<br>}</pre><p>After:</p><pre>import org.springframework.web.service.annotation.ImportHttpServices;</pre><pre>@Configuration<br>@ImportHttpServices(InventoryClient.class)<br>class ClientConfig {<br>}</pre><pre>grep -rn &quot;TestRestTemplate\|HttpServiceProxyFactory\|import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest&quot; src/test/</pre><h3>Update Security filter chain patterns</h3><p>Spring Security 7 (shipped with Boot 4) finalized several deprecations. The most common code change we’ll see is in SecurityFilterChain configuration.</p><p>Before:</p><pre>http<br>  .authorizeHttpRequests(auth -&gt; auth<br>    .requestMatchers(&quot;/api/**&quot;).authenticated()<br>    .anyRequest().permitAll()<br>  )<br>  .csrf(csrf -&gt; csrf.ignoringRequestMatchers(&quot;/api/**&quot;));</pre><p>Common changes after upgrading:</p><ul><li>requestMatchers() method signatures may require explicit HttpMethod parameters in some cases</li><li>CSRF token handling defaults changed — test CSRF-protected flows explicitly</li><li>Session management defaults tightened</li></ul><p>There is no single find-and-replace here. Run your security tests and review the <a href="https://docs.spring.io/spring-security/reference/migration-7/index.html">Spring Security 7 migration guide</a> for your specific patterns.</p><h3>Strengthen contract tests before rollout</h3><p>Before we promote to production, this is a good time to add or strengthen:</p><ul><li>API payload contract tests</li><li>Serialization/deserialization fixture tests</li><li>Security behavior tests (authz/authn boundaries)</li><li>Canary smoke tests against production-like data and config</li></ul><h3>Step 6: Production Rollout and CI/CD Gates</h3><p>We’ve made it through the code changes. Now let’s talk about getting this into production safely. The key principle: progressive delivery, not big-bang cutover.</p><h3>Rollout sequence</h3><ol><li>Pre-prod full integration run with production-like config</li><li>Canary deployment with explicit error budget guardrails</li><li>Monitor serialization errors, 4xx/5xx deltas, auth failures, and DB anomalies</li><li>Rollback criteria defined before promotion</li></ol><p>Track at least:</p><ul><li>startup time</li><li>memory footprint</li><li>p95/p99 latency on key endpoints</li><li>error rates by endpoint</li><li>security scanner deltas before/after</li></ul><h3>Gate A: Dependency and lifecycle drift</h3><p>Fail fast when unsupported or unexpected versions appear.</p><pre># Maven<br>mvn -q -DskipTests dependency:tree -DoutputFile=dependency-tree.txt</pre><pre># Gradle<br>./gradlew dependencies &gt; dependency-tree.txt</pre><p>Enforce: no unresolved dependency versions, no unexpected downgrades after merge, no dependencies from blocked version ranges.</p><h3>Gate B: JSON contract regression</h3><p>This is where we catch Jackson 2 to 3 behavior drift before canary.</p><pre>mvn -q -Dtest=&#39;*ContractTest&#39; test<br># or<br>./gradlew test --tests &#39;*ContractTest&#39;</pre><p>Recommended fixtures: date/time payloads, enum values and unknown enum inputs, null/default handling, polymorphic payloads.</p><h3>Gate C: Startup and smoke in production-like profile</h3><p>This gate catches missing starters and auto-config early.</p><pre>mvn -q -Dspring.profiles.active=staging verify<br># or<br>./gradlew test -Dspring.profiles.active=staging</pre><p>Include: application context startup test, one authenticated endpoint smoke test, one DB-backed flow smoke test.</p><h3>Gate D: Security advisory monitoring</h3><p>We want the pipeline to fail when known high/critical advisories affect runtime deps.</p><p>Options: OWASP Dependency-Check, Snyk, or GitHub Dependabot with code scanning policies. Block release on critical vulnerabilities without an approved exception. Time-bound exceptions with owner and remediation due date.</p><h3>Gate E: Canary promotion guardrails</h3><p>Track for the canary window:</p><ul><li>5xx rate delta vs baseline</li><li>p95/p99 latency delta vs baseline</li><li>Auth failure anomalies</li><li>Serialization/deserialization exception spikes</li></ul><p>Promote only if all SLO deltas stay within thresholds for the full canary window. Auto-rollback if error budget burn exceeds your policy.</p><h3>Common Pitfalls</h3><p>Here are the mistakes I’ve seen teams make most often:</p><ul><li>Upgrading Boot but leaving non-Boot managed dependencies on incompatible versions</li><li>Keeping old starter coordinates and relying on transitive luck</li><li>Missing the new explicit starters for RestClient, WebClient, and Flyway</li><li>Forgetting Boot’s own Jackson class renames (@JsonComponent, Jackson2ObjectMapperBuilderCustomizer)</li><li>Underestimating test annotation and test client migration work</li><li>Assuming Jackson migration is only import renaming</li><li>Not adding @AutoConfigureMockMvc after upgrading and wondering why MockMvc is null</li><li>Running with compatibility flags forever and never converging</li><li>Treating CVE remediation as a one-time task instead of continuous practice</li><li>Upgrading Spring Modulith to 2.0 without running the event publication schema migration first</li></ul><h3>Checklist</h3><ul><li>Latest 3.5.x deployed and stable</li><li>3.x deprecations addressed</li><li>Java/Jakarta/Servlet baseline validated for 4.0</li><li>Removed features audited (Undertow, launch scripts, etc.)</li><li>Starter graph reviewed — including new explicit starters (RestClient, WebClient, Flyway, security-test)</li><li>Package relocations updated (EntityScan, BootstrapRegistry)</li><li>Jackson migration strategy chosen (native vs bridge)</li><li>Boot Jackson class renames applied (@JacksonComponent, JsonMapperBuilderCustomizer)</li><li>Contract tests added for JSON and API behavior</li><li>@MockBean/@SpyBean usage migrated</li><li>@AutoConfigureMockMvc added where needed</li><li>TestRestTemplate → RestTestClient migration done</li><li>@WebMvcTest import updated to new package</li><li>Health probe and DevTools defaults reviewed</li><li>Spring Modulith event publication schema migrated (if applicable)</li><li>Testcontainers artifacts and imports updated (if applicable)</li><li>Canary and rollback plan validated</li><li>Compatibility flags tracked with removal dates</li></ul><h3>Final Takeaway</h3><p>If I had to summarize this entire playbook in one word, it would be explicitness:</p><ul><li>explicit dependencies</li><li>explicit JSON behavior</li><li>explicit rollout controls</li></ul><p>If we run this as a platform migration, not a version bump, the move is predictable and safe.</p><p>If you’re still on Spring Boot 3.5 close to EOL, start now while you still have room to test and iterate without emergency pressure.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35d5b542c88a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Spring Boot 3.5 is out of support. A practical, step-by-step Spring Boot 4 migration guide.]]></title>
            <link>https://mirfanarshad.medium.com/spring-boot-3-5-is-out-of-support-a-practical-step-by-step-spring-boot-4-migration-guide-2c96218d6522?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/2c96218d6522</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring-framework]]></category>
            <category><![CDATA[migration]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Mon, 02 Nov 2026 07:55:04 GMT</pubDate>
            <atom:updated>2026-11-02T07:55:04.540Z</atom:updated>
            <content:encoded><![CDATA[<p>Open-source support for Spring Boot 3.x ended on June 30, 2026. Here’s the migration order that keeps large codebases moving — and the changes that compile fine but break in production.</p><p>Spring Boot 3.5 reached end of life on June 30, 2026. Target Spring Boot 4.1.x (Java 17+). Clear 3.5 deprecations, switch versions with the properties migrator and classic starters as a bridge, migrate to Jackson 3 and @MockitoBean, then adopt the modular starters. Watch for silent changes: Spring Batch in-memory metadata, Undertow removal, optional dependencies and message converters.</p><p>Spring Boot 3.5’s open-source support ended on June 30, 2026; 3.5.16 was the last free patch. Every 3.x application is now running without community security fixes. Spring Boot 4 is a genuine generational change — Spring Framework 7, Jakarta EE 11, Jackson 3, a modular set of starters and JSpecify null-safety — so this isn’t a version bump you do on a Friday afternoon.</p><p>Here is the order I’d do it in, based on the official migration guide, with the traps that turn into production incidents called out explicitly.</p><h3>Step 0: pick the right target</h3><p>Spring Boot 4.0 was released in November 2025 and 4.1 in June 2026. 4.0’s own open-source support window is short, so if you’re starting now, target the latest 4.1.x. Boot 4 keeps the Java 17 baseline, though running on Java 25 LTS is encouraged.</p><h3>Step 1: get clean on the latest 3.5.x first</h3><p>Upgrade to the newest 3.5 release and fix every deprecation warning. Anything deprecated in 3.x has been removed in 4.0 — so a warning today is a compile error tomorrow. This step alone removes a large share of the migration pain.</p><h3>Step 2: switch the parent and add the properties migrator</h3><p>Bump the Spring Boot version, then add the properties migrator temporarily. At startup it reports renamed or removed configuration keys and maps them for you at runtime, so you can see exactly what to change.</p><p>pom.xml</p><pre>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-properties-migrator&lt;/artifactId&gt;<br>    &lt;scope&gt;runtime&lt;/scope&gt;<br>&lt;/dependency&gt;<br>&lt;!-- Remove this once the startup report is clean --&gt;</pre><h3>Step 3: use the classic starters to get compiling</h3><p>Boot 4 splits its big auto-configuration jar into focused modules. The fastest way to get a large codebase compiling is to temporarily swap in the classic starters, which restore a Boot 3-like classpath. Fix imports and tests there, then come back and adopt the modular starters properly.</p><pre>&lt;!-- spring-boot-starter       -&gt; spring-boot-starter-classic --&gt;<br>&lt;!-- spring-boot-starter-test  -&gt; spring-boot-starter-test-classic --&gt;<br>&lt;dependency&gt;<br>    &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;<br>    &lt;artifactId&gt;spring-boot-starter-classic&lt;/artifactId&gt;<br>&lt;/dependency&gt;</pre><h3>Step 4: move to Jackson 3</h3><p>This is where most compile errors come from. Jackson 3 changes group IDs and packages from com.fasterxml.jackson to tools.jackson — except annotations, which stay in com.fasterxml.jackson.annotation. Spring Boot now auto-configures a JsonMapper, so an ObjectMapper bean no longer replaces the default.</p><pre>// Spring Boot 3.x<br>@Bean<br>Jackson2ObjectMapperBuilderCustomizer jsonCustomizer() {<br>    return builder -&gt; builder.failOnUnknownProperties(false);<br>}<br><br>// Spring Boot 4.x<br>@Bean<br>JsonMapperBuilderCustomizer jsonCustomizer() {<br>    return builder -&gt; builder.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);<br>}</pre><p>Also rename @JsonComponent to @JacksonComponent and @JsonMixin to @JacksonMixin. If output differences break clients, spring.jackson.use-jackson2-defaults=true aligns defaults with Boot 3 while you migrate.</p><h3>Step 5: fix the tests</h3><p>Three test changes catch almost everyone. @MockBean and @SpyBean are gone — use @MockitoBean and @MockitoSpyBean. @SpringBootTest no longer sets up MockMvc on its own. And TestRestTemplate now needs an explicit annotation (or switch to the new RestTestClient).</p><pre>@SpringBootTest<br>@AutoConfigureMockMvc              // no longer implied by @SpringBootTest<br>class LoanControllerIT {<br><br>    @MockitoBean                   // replaces @MockBean<br>    LoanService loanService;<br><br>    @Autowired<br>    MockMvc mockMvc;<br>}</pre><h3>Step 6: adopt the modular starters</h3><p>Remove the classic starters and let the missing imports tell you which starters you need. Several were renamed: spring-boot-starter-web becomes spring-boot-starter-webmvc, spring-boot-starter-aop becomes spring-boot-starter-aspectj, and the OAuth2 starters gain a security- prefix. Technologies that used to need only a third-party jar — Flyway and Liquibase are the common ones — now need their own starter. Each starter also has a -test companion.</p><p><strong>The migration traps that become production incidents</strong></p><p><strong>Spring Batch now defaults to in-memory metadata.</strong> With plain spring-boot-starter-batch, job history stops being written to your database — switch to spring-boot-starter-batch-jdbc if you depend on restartability. <strong>Undertow is gone</strong> (it doesn&#39;t support Servlet 6.1); move to Tomcat or Jetty. <strong>Optional Maven dependencies are no longer packaged</strong> into the uber jar. <strong>Custom </strong><strong>HttpMessageConverter beans are no longer picked up</strong> — use the new converter customizers. <strong>Spring Retry&#39;s dependency management was removed</strong> in favour of the retry support now built into Spring Framework 7. And liveness/readiness probes are now enabled by default — good news for Kubernetes, but check your health endpoint security.</p><h3>Frequently asked questions</h3><h3>When did Spring Boot 3.5 reach end of life?</h3><p>Spring Boot 3.5 reached open-source end of life on June 30, 2026. The final free release was 3.5.16. After that date, no further open-source patches are published.</p><h3>Does Spring Boot 4 require Java 21?</h3><p>No. Spring Boot 4 requires Java 17 or later, the same baseline as Spring Boot 3. Using the latest LTS, Java 25, is encouraged.</p><h3>What is the fastest way to migrate a large app to Spring Boot 4?</h3><p>Upgrade to the latest 3.5.x and clear deprecations, move to Boot 4 using the classic starters and the properties migrator, fix Jackson 3 and test changes, then replace the classic starters with the new modular starters.</p><p>Spring Boot 3.x is <strong>out of open-source support</strong>; target <strong>4.1.x</strong>.</p><p>Clear <strong>3.5 deprecations first</strong> — they’re removed in 4.0.</p><p>Use <strong>classic starters + properties migrator</strong> as a bridge, then go modular.</p><p>Budget time for <strong>Jackson 3</strong> and <strong>test annotation</strong> changes.</p><p>Check the silent ones: <strong>Spring Batch metadata, Undertow, optional deps, message converters</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2c96218d6522" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Best MCP Servers in 2026 & Setting up MCP servers in Claude Code]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mirfanarshad.medium.com/the-best-mcp-servers-in-2026-setting-up-mcp-servers-in-claude-code-cd263c2c313c?source=rss-6b06f9eac049------2"><img src="https://cdn-images-1.medium.com/max/1536/1*49ERE4VNfs-noDhv4Wd3DA.png" width="1536"></a></p><p class="medium-feed-snippet">This post is the opposite of that list. It&#x2019;s a short, opinionated set of the best MCP servers we&#x2019;d actually recommend installing in 2026&#x2026;</p><p class="medium-feed-link"><a href="https://mirfanarshad.medium.com/the-best-mcp-servers-in-2026-setting-up-mcp-servers-in-claude-code-cd263c2c313c?source=rss-6b06f9eac049------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mirfanarshad.medium.com/the-best-mcp-servers-in-2026-setting-up-mcp-servers-in-claude-code-cd263c2c313c?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/cd263c2c313c</guid>
            <category><![CDATA[mcp-protocol]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[mcp-server]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Thu, 13 Aug 2026 06:59:37 GMT</pubDate>
            <atom:updated>2026-08-13T06:59:37.463Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[10+ Best Text-to-Video AI Generators: Powerful and Free]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mirfanarshad.medium.com/10-best-text-to-video-ai-generators-powerful-and-free-665ed8765742?source=rss-6b06f9eac049------2"><img src="https://cdn-images-1.medium.com/max/1024/0*Ahrn227mHdwkLrNq.jpg" width="1024"></a></p><p class="medium-feed-snippet">AI Video creation when text comes to real</p><p class="medium-feed-link"><a href="https://mirfanarshad.medium.com/10-best-text-to-video-ai-generators-powerful-and-free-665ed8765742?source=rss-6b06f9eac049------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mirfanarshad.medium.com/10-best-text-to-video-ai-generators-powerful-and-free-665ed8765742?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/665ed8765742</guid>
            <category><![CDATA[generative-ai-tools]]></category>
            <category><![CDATA[video-production]]></category>
            <category><![CDATA[free-ai-text-to-video]]></category>
            <category><![CDATA[text-to-video]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:22:08 GMT</pubDate>
            <atom:updated>2026-07-28T07:22:08.267Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[I Used All 4 Claude Apps. Here’s Which One You Should Pick]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-snippet">Anthropic has shipped two new Claude-based tools in 2026, which means they now have four unique ways to build with Claude. This diversity&#x2026;</p><p class="medium-feed-link"><a href="https://mirfanarshad.medium.com/i-used-all-4-claude-apps-heres-which-one-you-should-pick-a37788d70325?source=rss-6b06f9eac049------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mirfanarshad.medium.com/i-used-all-4-claude-apps-heres-which-one-you-should-pick-a37788d70325?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/a37788d70325</guid>
            <category><![CDATA[claude-ai]]></category>
            <category><![CDATA[claude]]></category>
            <category><![CDATA[claude-cowork]]></category>
            <category><![CDATA[claude-code]]></category>
            <category><![CDATA[claude-design]]></category>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Tue, 28 Jul 2026 07:01:55 GMT</pubDate>
            <atom:updated>2026-07-28T07:01:55.294Z</atom:updated>
        </item>
        <item>
            <title><![CDATA[Architecture of Spring Boot: Examples, Pattern, Layered, Controller Layer]]></title>
            <link>https://mirfanarshad.medium.com/architecture-of-spring-boot-examples-pattern-layered-controller-layer-703b56360a36?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/703b56360a36</guid>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Mon, 05 Jan 2026 16:12:09 GMT</pubDate>
            <atom:updated>2026-01-06T08:25:02.938Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U3fIEji_C-2qNZsqljKr-w.jpeg" /><figcaption><em>Master the architecture of Spring Boot with our insightful blog. We’ll illustrate key concepts through examples, design patterns, and discuss the significance of a well-structured layered approach!</em></figcaption></figure><p><strong>Architecture of Spring Boot:</strong> Several application development frameworks are available, but one of the most popular frameworks when working with Java is the Spring framework. You will be completely fascinated with the Spring framework and its ability to manage applications.</p><p>Spring Boot is a Spring Framework module. It is used to quickly construct standalone, production-grade Spring Based Applications. It is built on top of the Spring Framework. Spring Boot has a layered architecture in which each layer communicates with the layer below or above it.</p><p>In this article, we will learn about the architecture of Spring Boot. We will also learn about the different layers in the Spring Boot architecture. We will also learn about flow in Spring Boot Architecture.</p><h3>Table of Contents</h3><ul><li>Spring Boot Architecture Example</li><li>Spring Boot Architecture Patterns</li><li>Spring Boot Layered Architecture Example</li><li>Architecture of Spring Boot Microservices</li><li>Controller Layer in Spring Boot</li><li>What is Spring Boot Architecture?</li><li>What Is the Production Architecture of Spring Boot?</li><li>What is the Architecture of Spring Boot Repository?</li><li>What is 3 tier Architecture in Spring Boot?</li><li>Architecture of Spring Boot FAQs</li><li>What is the key component of Spring Boot architecture?</li><li>How does Spring Boot simplify configuration?</li><li>What role does the Spring Boot Actuator play in production?</li><li>How does Spring Boot support containerization?</li><li>What is the significance of Spring Boot Starters?</li></ul><p><strong>Spring Boot Architecture Example</strong></p><ul><li><strong>Controller Layer:</strong></li><li>This layer is responsible for handling incoming HTTP requests.</li><li>Controllers receive requests, process them, and interact with the service layer to retrieve or manipulate data.</li><li>Controllers are often annotated with @Controller or @RestController.</li><li><strong>Service Layer:</strong></li><li>The service layer contains business logic and acts as an intermediary between the controller and the data access layer.</li><li>It encapsulates the application’s business logic, ensuring separation of concerns.</li><li>Services are often annotated with @Service.</li><li><strong>Repository/DAO Layer:</strong></li><li>This layer is responsible for interacting with the database or any external data source.</li><li>It includes interfaces or classes that define methods for performing CRUD (Create, Read, Update, Delete) operations.</li><li>Repositories are often annotated with @Repository.</li><li><strong>Entity Layer:</strong></li><li>Entities represent the application’s data model and are often mapped to database tables.</li><li>These classes typically contain fields annotated with JPA annotations (@Entity, @Column, etc.) for database mapping.</li><li><strong>DTO (Data Transfer Object):</strong></li><li>DTOs are used to transfer data between layers and can help to encapsulate the data being sent between the client and the server.</li><li>They can be used to shape the data for presentation without exposing the internal entity structure.</li><li><strong>Security Layer:</strong></li><li>This layer is responsible for handling authentication and authorization.</li><li>Spring Security is commonly used to secure Spring Boot applications, providing features like authentication, authorization, and protection against common security vulnerabilities.</li><li><strong>Configuration Layer:</strong></li><li>This layer includes configuration files and classes.</li><li>Configuration can be done using annotations like @Configuration, @Bean, or through XML configuration.</li></ul><p>Remember that Spring Boot is highly customizable, and the architecture can be adapted based on project requirements. This overview provides a general structure that many Spring Boot applications follow.</p><h3>Spring Boot Architecture Patterns</h3><p>Spring Boot applications often follow certain architectural patterns to achieve modularity, scalability, and maintainability. Here are some common architectural patterns used in Spring Boot development:</p><ul><li><strong>MVC (Model-View-Controller):</strong></li><li>Spring Boot follows the MVC pattern for building web applications.</li><li><strong>Model:</strong> Represents the application’s data and business logic.</li><li><strong>View:</strong> Responsible for rendering the user interface.</li><li><strong>Controller:</strong> Handles user requests, interacts with the model, and updates the view.</li><li><strong>Microservices Architecture:</strong></li><li>Spring Boot is commonly used in microservices architectures where the application is decomposed into small, independently deployable services.</li><li>Each microservice is responsible for a specific business capability and communicates with other services through APIs.</li><li><strong>Restful API Design:</strong></li><li>Spring Boot promotes the design of RESTful APIs for communication between components.</li><li>Controllers expose RESTful endpoints, and data is typically exchanged in JSON format.</li><li><strong>Layered Architecture:</strong></li><li>Organising the application into layers like presentation, service, repository, and entity helps maintain a separation of concerns.</li><li>This layered architecture promotes modularity and testability.</li><li><strong>Dependency Injection (DI) / Inversion of Control (IoC):</strong></li><li>Spring Boot relies heavily on the principle of dependency injection, where dependencies are injected into components rather than being created by the components themselves.</li><li>This reduces tight coupling and makes the application more maintainable.</li><li><strong>Event-Driven Architecture:</strong></li><li>Spring Boot supports event-driven architecture through the use of Spring Events.</li><li>Components can publish and subscribe to events, allowing for loosely coupled communication between different parts of the application.</li><li><strong>CQRS (Command Query Responsibility Segregation):</strong></li><li>CQRS separates read and write operations, allowing for independent scaling of the query (read) and command (write) sides.</li><li>Spring Boot can be used to implement CQRS patterns using different components for command and query responsibilities.</li><li><strong>Saga Pattern:</strong></li><li>In microservices architectures, the saga pattern is often used to manage distributed transactions.</li><li>Spring Boot applications can implement sagas by coordinating a series of transactions across multiple microservices.</li><li><strong>Gateway Pattern:</strong></li><li>API gateways are used to manage and route requests in microservices architectures.</li><li>Spring Cloud provides tools like Spring Cloud Gateway for building API gateways.</li></ul><p>These patterns can be combined and adapted based on the specific requirements of the application. The flexibility of Spring Boot allows developers to choose and implement the patterns that best suit their needs.</p><h3>Spring Boot Layered Architecture Example</h3><p>Let’s walk through a layered architecture example for a Spring Boot application without providing specific code. This example assumes a typical three-layered architecture: Presentation, Service, and Data Access layers.</p><p><strong>Presentation Layer:</strong></p><ol><li>This layer handles the interaction with the user, receives HTTP requests, and sends responses.</li><li>Controllers in this layer are annotated with @RestController.</li><li>The controllers interact with the Service layer to process requests and obtain results.</li><li>DTOs (Data Transfer Objects) may be used to transfer data between the Presentation and Service layers.</li></ol><p><strong>Service Layer:</strong></p><ol><li>The Service layer contains business logic and orchestrates the flow of data between the Presentation and Data Access layers.</li><li>Service classes are annotated with @Service.</li><li>They use the Data Access layer to retrieve or manipulate data.</li><li>This layer is responsible for enforcing business rules and ensuring data consistency.</li></ol><p><strong>Data Access Layer:</strong></p><ol><li>The Data Access layer is responsible for interacting with the database or any other data source.</li><li>It includes repository interfaces or classes annotated with @Repository.</li><li>Entities represent the data model and are often annotated with JPA annotations for database mapping.</li></ol><p><strong>Example Workflow:</strong></p><ol><li>A user sends an HTTP request to a REST endpoint in the Presentation layer.</li><li>The controller in the Presentation layer receives the request and invokes the appropriate method in the Service layer.</li><li>The Service layer performs business logic, possibly involving multiple service classes, and interacts with the Data Access layer to retrieve or persist data.</li><li>The Data Access layer communicates with the database to perform CRUD operations on entities.</li><li>The Service layer returns the result to the Presentation layer, possibly transforming entities into DTOs.</li><li>The Presentation layer sends an HTTP response to the user.</li></ol><p><strong>Benefits:</strong></p><ul><li><strong>Modularity:</strong> Each layer has a specific responsibility, making the application more modular and easier to maintain.</li><li><strong>Separation of Concerns:</strong> The separation of layers allows for a clear distinction between presentation, business logic, and data access concerns.</li><li><strong>Testability:</strong> Each layer can be tested independently, promoting easier unit testing and maintenance.</li><li><strong>Scalability:</strong> Components can be scaled independently based on the specific needs of each layer.</li></ul><p><strong>Considerations:</strong></p><ul><li>Care should be taken to avoid tight coupling between layers. Dependency injection and interfaces can help achieve loose coupling.</li><li>DTOs may be used to transfer data between layers, but excessive use should be avoided to prevent overcomplicating the architecture.</li></ul><p>Remember that this is a high-level overview, and specific project requirements may lead to variations in the architecture.</p><h3>Architecture of Spring Boot Microservices</h3><p>The architecture of Spring Boot microservices typically follows principles that align with the characteristics of microservices, such as modularity, independence, and distributed systems. Here’s a conceptual overview of the architecture for a Spring Boot microservices application:</p><p><strong>Microservices:</strong></p><ul><li>The application is decomposed into small, independent, and loosely coupled services, each focused on a specific business capability.</li><li>Microservices communicate with each other through well-defined APIs, often exposed as RESTful endpoints.</li></ul><p><strong>Service Registry and Discovery:</strong></p><ul><li>Services register themselves with a service registry (e.g., Spring Cloud Netflix Eureka).</li><li>Service discovery allows services to locate and communicate with each other dynamically.</li></ul><p><strong>API Gateway:</strong></p><ul><li>An API Gateway (e.g., Spring Cloud Gateway, Netflix Zuul) is used to manage and route external requests to the appropriate microservices.</li><li>It can handle authentication, load balancing, and routing.</li></ul><p><strong>Configuration Management:</strong></p><ul><li>Centralised configuration management (e.g., Spring Cloud Config) allows microservices to retrieve configuration properties dynamically.</li><li>Configuration can be stored in a version-controlled repository and updated without redeploying services.</li></ul><p><strong>Distributed Data Management:</strong></p><ul><li>Microservices often have their own databases, and the choice of database depends on the specific requirements of each service.</li><li>Eventual consistency and distributed data management strategies may be employed.</li></ul><p><strong>Event-Driven Architecture:</strong></p><ul><li>Events and messaging systems (e.g., Spring Cloud Stream, Apache Kafka) are used for communication between microservices.</li><li>Event-driven architecture supports loose coupling and scalability.</li><li><strong>Polyglot Architecture:</strong></li><li>Each microservice can be implemented in a different programming language or use a different technology stack, known as a polyglot architecture.</li><li>The choice of technology is based on the specific requirements of each service.</li></ul><p><strong>Testing and Continuous Integration/Continuous Deployment (CI/CD):</strong></p><ul><li>Microservices are independently testable, allowing for easier unit testing and integration testing.</li><li>CI/CD pipelines enable automated testing and deployment of microservices.</li></ul><p><strong>Domain-Driven Design (DDD):</strong></p><ul><li>Microservices are often designed based on domain-driven design principles, emphasising a clear understanding of the business domain and its interactions.</li></ul><p>This architecture allows for flexibility, scalability, and easy maintenance of a microservices-based system. Spring Cloud provides a set of tools and libraries to implement many of these patterns and streamline the development of microservices in a Spring Boot environment.</p><h3>Controller Layer in Spring Boot</h3><p>In a Spring Boot application, the controller layer is a crucial component responsible for handling incoming HTTP requests, processing them, and producing appropriate responses. It plays a key role in the Model-View-Controller (MVC) architectural pattern. Below are key aspects and responsibilities of the controller layer in Spring Boot:</p><ul><li><strong>Annotation:</strong></li><li>Controllers are typically annotated with @Controller or @RestController. The @RestController annotation is often used for RESTful APIs and includes the @Controller and @ResponseBody annotations.</li><li><strong>Request Mapping:</strong></li><li>Controllers define methods that handle specific HTTP requests. These methods are annotated with @RequestMapping or more specialised annotations like @GetMapping, @PostMapping, etc.</li><li>Request mappings specify the URI path and HTTP method that the method should respond to.</li><li><strong>Method Parameters:</strong></li><li>Controller methods can have parameters that are automatically populated with data from the HTTP request, such as path variables (@PathVariable), request parameters (@RequestParam), request headers (@RequestHeader), and the request body.</li><li><strong>Response Handling:</strong></li><li>Controller methods return data that will be included in the HTTP response. The return type can be a Java object, which is automatically converted to JSON (or another format) using Spring’s content negotiation.</li><li>For RESTful APIs, the @ResponseBody annotation can be used to indicate that the return value should be serialised directly to the response body.</li><li><strong>View Rendering (for MVC):</strong></li><li>In traditional MVC applications, where server-side rendering is used, the controller may return a logical view name that is resolved by the ViewResolver to an actual view template.</li><li>For RESTful APIs, the focus is on data returned as JSON or XML rather than rendering HTML views.</li><li><strong>Exception Handling:</strong></li><li>Controllers can handle exceptions using @ExceptionHandler methods. These methods define how the application should respond when a specific exception occurs during request processing.</li><li><strong>Validation:</strong></li><li>Controllers may perform input validation by using validation annotations such as @Valid in method parameters. Validation errors can be captured and handled in the controller.</li><li><strong>Interception and Filters:</strong></li><li>Controllers can be intercepted using interceptors (HandlerInterceptor) to perform pre- or post-processing logic.</li><li>Filters (javax.servlet.Filter) can also be applied at the servlet level for more fine-grained request processing.</li><li><strong>Cross-Origin Resource Sharing (CORS) Handling:</strong></li><li>For web applications, controllers can configure CORS settings using annotations like @CrossOrigin to control which domains are allowed to access the resources.</li><li><strong>Security:</strong></li><li>Controllers often play a role in handling security aspects such as authentication and authorization. Spring Security can be integrated to secure controller methods.</li><li><strong>Testing:</strong></li><li>Controllers are unit-testable. Spring provides testing support through @WebMvcTest for testing the controller layer in isolation.</li></ul><p>The controller layer acts as an interface between the external world (HTTP requests) and the application’s business logic (service layer). It helps in maintaining a clear separation of concerns in the application architecture.</p><h3>What is Spring Boot Architecture?</h3><p>Spring Boot follows a modular and opinionated architectural pattern that simplifies the development of production-ready, stand-alone Spring-based applications. It builds on the concepts of the broader Spring Framework and provides defaults for convention over configuration, allowing developers to quickly set up and deploy applications.</p><p>Here’s an overview of the key components in the architecture of a Spring Boot application:</p><ul><li><strong>Standalone Application:</strong></li><li>Spring Boot applications are designed to be standalone, meaning they are self-contained and can be run with minimum configuration. They don’t require external servlet containers like Tomcat or Jetty, as they embed an embedded server (typically Tomcat, Jetty, or Undertow).</li><li><strong>Opinionated Defaults:</strong></li><li>Spring Boot provides a set of defaults and conventions for configuration, reducing the need for extensive boilerplate code.</li><li>It aims to minimise the effort required for developers to configure and set up the application, making it easier to get started quickly.</li><li><strong>Spring Framework Core:</strong></li><li>At its core, Spring Boot is built on top of the Spring Framework. It inherits the fundamental concepts of Inversion of Control (IoC), Dependency Injection (DI), and Aspect-Oriented Programming (AOP) from the Spring Framework.</li></ul><h3>What Is the Production Architecture of Spring Boot?</h3><p>The production architecture of a Spring Boot application typically involves deploying microservices in containerized environments with orchestration (e.g., Kubernetes), load balancing, and service discovery. Cloud-native principles, such as containerization with Docker, API gateways (e.g., Spring Cloud Gateway), security measures (e.g., OAuth), and continuous integration/deployment (CI/CD) pipelines are employed. Monitoring tools (e.g., Spring Boot Actuator), logging (e.g., SLF4J with Logback), and resilience patterns (e.g., circuit breakers) ensure robustness.</p><p>The choice of databases, scalability, and adherence to compliance regulations contribute to a production-ready architecture, providing high availability, fault tolerance, and efficient resource utilisation.</p><p><strong>Also Read: </strong><a href="https://pwskills.com/blog/spring-boot-rest-api-tutorial-best-practices-and-examples/"><strong>Spring Boot Rest API: Rest APIS with Java and Spring Boot</strong></a></p><h3>What is the Architecture of Spring Boot Repository?</h3><p>The architecture of a Spring Boot repository typically involves the use of Spring Data JPA or other data access technologies. Repositories, annotated with @Repository, encapsulate data access logic and connect the application’s service layer to the underlying database. Entities represent the data model, annotated with JPA annotations for database mapping.</p><p>The Service layer orchestrates business logic and interacts with repositories to perform CRUD operations. Spring Boot’s auto-configuration simplifies repository setup, and custom repositories may extend CrudRepository or JpaRepository. This architecture supports modular, maintainable, and scalable applications with efficient database interactions.</p><h3>What is 3 tier Architecture in Spring Boot?</h3><p>The 3-tier architecture in Spring Boot divides an application into three layers: Presentation, Service, and Data Access. The Presentation layer includes controllers handling user interactions, the Service layer encapsulates business logic, and the Data Access layer manages interactions with the database.</p><p>Controllers process HTTP requests, invoking service methods that orchestrate business logic. Service classes interact with repositories or DAOs, which, in turn, perform database operations on entities. This modular architecture enhances maintainability, scalability, and separation of concerns, allowing each layer to be developed and tested independently, fostering a clearer organisation of code and facilitating future modifications.</p><p>Spring Boot offers a streamlined architecture for building Java applications. Its key features include auto-configuration, embedded servers, and a simplified setup, making it a popular choice for developing robust and production-ready applications with minimal boilerplate code and configuration.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=703b56360a36" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Improve app performance with optimized resource shrinking]]></title>
            <description><![CDATA[<div class="medium-feed-item"><p class="medium-feed-image"><a href="https://mirfanarshad.medium.com/improve-app-performance-with-optimized-resource-shrinking-9ee57f545d24?source=rss-6b06f9eac049------2"><img src="https://cdn-images-1.medium.com/max/1536/0*GH6EVAlZDgbipAfn" width="1536"></a></p><p class="medium-feed-snippet">Make Your Android Apps Smaller and Faster with Optimized Resource Shrinking in R8</p><p class="medium-feed-link"><a href="https://mirfanarshad.medium.com/improve-app-performance-with-optimized-resource-shrinking-9ee57f545d24?source=rss-6b06f9eac049------2">Continue reading on Medium »</a></p></div>]]></description>
            <link>https://mirfanarshad.medium.com/improve-app-performance-with-optimized-resource-shrinking-9ee57f545d24?source=rss-6b06f9eac049------2</link>
            <guid isPermaLink="false">https://medium.com/p/9ee57f545d24</guid>
            <dc:creator><![CDATA[irfan arshad]]></dc:creator>
            <pubDate>Thu, 02 Oct 2025 19:54:13 GMT</pubDate>
            <atom:updated>2025-10-02T19:54:13.082Z</atom:updated>
        </item>
    </channel>
</rss>