惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
爱范儿
爱范儿
P
Proofpoint News Feed
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
T
Tailwind CSS Blog
J
Java Code Geeks
宝玉的分享
宝玉的分享
Jina AI
Jina AI
B
Blog
N
Netflix TechBlog - Medium
Recent Announcements
Recent Announcements
aimingoo的专栏
aimingoo的专栏
腾讯CDC
C
Check Point Blog
The Cloudflare Blog
阮一峰的网络日志
阮一峰的网络日志
博客园 - Franky
罗磊的独立博客
B
Blog RSS Feed
WordPress大学
WordPress大学
小众软件
小众软件
博客园 - 叶小钗
M
MIT News - Artificial intelligence
GbyAI
GbyAI

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
I built a production-ready Spring Boot 4 Starter Kit (and...
Rahul Kushwaha · 2026-06-27 · via DEV Community
Cover image for I built a production-ready Spring Boot 4 Starter Kit (and Reddit roasted it into something better)

Rahul Kushwaha

Why I built this

Every new Spring Boot project starts the same way.

JWT setup. Security config. CORS. Rate limiting.
Docker. CI/CD. Exception handling.

I was copy-pasting the same boilerplate across projects,
so I decided to build it once, do it properly,
and open source it.


What's inside

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

Java 21 + Spring Boot 4


Reddit made it better

I posted on r/SpringBoot and r/java.
The feedback was brutal. And valuable.

Criticism 1:

"Why are you making a DB call on every request?
That defeats the purpose of JWT."

They were right. My JWT filter was loading the user
from DB on every request to get roles.
Completely stateless JWT was the whole point.

Fix: Embedded roles directly into JWT claims at
login time. Filter now extracts roles from token —
zero DB calls per request.

Criticism 2:

"Why not store tokens in HTTP-only cookies?
Bearer headers are XSS vulnerable in browsers."

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

Criticism 3:

"Spring Security already handles this with
AbstractAuthenticationProcessingFilter.
You don't need a custom JWT filter."

This one was more nuanced. They suggested
Spring Session + JDBC instead of JWT entirely.

So I added both approaches:

  • main branch → JWT (stateless, mobile-friendly)
  • feature/spring-session → Spring Session JDBC (simpler, instant revocation, survives restarts)

Devs can pick what fits their use case.


How to use it

git clone https://github.com/raahulllkushwaha/springboot-starter-kit
cd springboot-starter-kit

# runs on H2 in-memory — zero setup
mvn spring-boot:run

Open http://localhost:8080/swagger-ui.html

Register → Login → copy token → hit protected endpoints.

For production:

cp .env.example .env
# fill your secrets
docker compose up -d


Rename for your project

Find & replace com.starterkitcom.yourcompany.app

Then add your entities on top. Auth, Docker,
CI/CD already done.


What I learned

  • Open source feedback > any code review
  • README quality matters more than code quality for adoption
  • JWT stateless = NO DB calls in filter. Period.
  • Spring Security's built-in flow exists for a reason

GitHub:

If this saves you time, a ⭐ means a lot.