<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Rahul Kushwaha</title>
    <description>The latest articles on DEV Community by Rahul Kushwaha (@raahulllkushwaha).</description>
    <link>https://dev.to/raahulllkushwaha</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4004754%2F933926be-63d8-49ed-8a9a-10d6dc8b97d8.png</url>
      <title>DEV Community: Rahul Kushwaha</title>
      <link>https://dev.to/raahulllkushwaha</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/raahulllkushwaha"/>
    <language>en</language>
    <item>
      <title>I built a production-ready Spring Boot 4 Starter Kit (and Reddit roasted it into something better)</title>
      <dc:creator>Rahul Kushwaha</dc:creator>
      <pubDate>Sat, 27 Jun 2026 03:33:12 +0000</pubDate>
      <link>https://dev.to/raahulllkushwaha/i-built-a-production-ready-spring-boot-4-starter-kit-and-reddit-roasted-it-into-something-better-4co4</link>
      <guid>https://dev.to/raahulllkushwaha/i-built-a-production-ready-spring-boot-4-starter-kit-and-reddit-roasted-it-into-something-better-4co4</guid>
      <description>&lt;p&gt;&lt;strong&gt;Why I built this&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every new Spring Boot project starts the same way.&lt;/p&gt;

&lt;p&gt;JWT setup. Security config. CORS. Rate limiting. &lt;br&gt;
Docker. CI/CD. Exception handling.&lt;/p&gt;

&lt;p&gt;I was copy-pasting the same boilerplate across projects, &lt;br&gt;
so I decided to build it once, do it properly, &lt;br&gt;
and open source it.&lt;/p&gt;


&lt;h2&gt;
  
  
  What's inside
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;🔐 JWT Auth — access token (15 min) + refresh token 
(7 days) with rotation&lt;/li&gt;
&lt;li&gt;👮 Role-based access — ROLE_USER, ROLE_ADMIN 
via @PreAuthorize&lt;/li&gt;
&lt;li&gt;🚦 Rate limiting — per IP using Bucket4j&lt;/li&gt;
&lt;li&gt;📄 Swagger UI — auto-generated at /swagger-ui.html&lt;/li&gt;
&lt;li&gt;🛡️ Global exception handling — consistent 
ApiResponse on every endpoint&lt;/li&gt;
&lt;li&gt;🗃️ Flyway migrations — version-controlled schema&lt;/li&gt;
&lt;li&gt;🐳 Docker + Nginx + MySQL — one command deploy&lt;/li&gt;
&lt;li&gt;⚙️ GitHub Actions CI/CD — test → build → EC2 deploy&lt;/li&gt;
&lt;li&gt;🍪 HTTP-only cookie support — XSS protection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Java 21 + Spring Boot 4&lt;/strong&gt;&lt;/p&gt;


&lt;h2&gt;
  
  
  Reddit made it better
&lt;/h2&gt;

&lt;p&gt;I posted on r/SpringBoot and r/java. &lt;br&gt;
The feedback was brutal. And valuable.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Criticism 1:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why are you making a DB call on every request? &lt;br&gt;
That defeats the purpose of JWT."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They were right. My JWT filter was loading the user &lt;br&gt;
from DB on every request to get roles. &lt;br&gt;
Completely stateless JWT was the whole point.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fix:&lt;/strong&gt; Embedded roles directly into JWT claims at &lt;br&gt;
login time. Filter now extracts roles from token — &lt;br&gt;
zero DB calls per request.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Criticism 2:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Why not store tokens in HTTP-only cookies? &lt;br&gt;
Bearer headers are XSS vulnerable in browsers."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Also valid. Added HTTP-only cookie support. &lt;br&gt;
Both Bearer header and cookie work simultaneously — &lt;br&gt;
browser apps use cookie, mobile/API clients use header.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Criticism 3:&lt;/strong&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Spring Security already handles this with &lt;br&gt;
AbstractAuthenticationProcessingFilter. &lt;br&gt;
You don't need a custom JWT filter."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This one was more nuanced. They suggested &lt;br&gt;
Spring Session + JDBC instead of JWT entirely.&lt;/p&gt;

&lt;p&gt;So I added both approaches:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;main&lt;/code&gt; branch → JWT (stateless, mobile-friendly)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;feature/spring-session&lt;/code&gt; → Spring Session JDBC 
(simpler, instant revocation, survives restarts)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Devs can pick what fits their use case.&lt;/p&gt;


&lt;h2&gt;
  
  
  How to use it
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;git clone https://github.com/raahulllkushwaha/springboot-starter-kit
&lt;span class="nb"&gt;cd &lt;/span&gt;springboot-starter-kit

&lt;span class="c"&gt;# runs on H2 in-memory — zero setup&lt;/span&gt;
mvn spring-boot:run
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Open &lt;code&gt;http://localhost:8080/swagger-ui.html&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Register → Login → copy token → hit protected endpoints.&lt;/p&gt;

&lt;p&gt;For production:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cp&lt;/span&gt; .env.example .env
&lt;span class="c"&gt;# fill your secrets&lt;/span&gt;
docker compose up &lt;span class="nt"&gt;-d&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Rename for your project
&lt;/h2&gt;

&lt;p&gt;Find &amp;amp; replace &lt;code&gt;com.starterkit&lt;/code&gt; → &lt;code&gt;com.yourcompany.app&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then add your entities on top. Auth, Docker, &lt;br&gt;
CI/CD already done.&lt;/p&gt;




&lt;h2&gt;
  
  
  What I learned
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Open source feedback &amp;gt; any code review&lt;/li&gt;
&lt;li&gt;README quality matters more than code quality 
for adoption&lt;/li&gt;
&lt;li&gt;JWT stateless = NO DB calls in filter. Period.&lt;/li&gt;
&lt;li&gt;Spring Security's built-in flow exists for a reason&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;GitHub: &lt;a href="https://github.com/raahulllkushwaha/springboot-starter-kit" rel="noopener noreferrer"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If this saves you time, a ⭐ means a lot.&lt;/p&gt;

</description>
      <category>java</category>
      <category>springboot</category>
      <category>opensource</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
