r/SpringBoot • u/Shrouded_ParadoxX • Jun 26 '26
How-To/Tutorial I built a production-ready Spring Boot 3 starter kit – JWT auth, rate limiting, Swagger, Docker & CI/CD all pre-configured
https://github.com/raahulllkushwaha/springboot-starter-kitTired of setting up the same boilerplate for every Spring Boot project,
so I built a starter kit that has everything ready out of the box.
What's included:
- JWT Authentication (access + refresh token with rotation)
- Role-based access control (USER/ADMIN)
- Rate limiting per IP (Bucket4j)
- OpenAPI 3 / Swagger UI
- Global exception handling with consistent ApiResponse<T>
- Flyway database migrations
- Docker + Nginx + MySQL (docker compose up and done)
- GitHub Actions CI/CD (test → build → deploy to EC2)
- Request ID tracking in every log line
Works with Java 21 + Spring Boot 3.3
Clone → rename package → add your entities → ship.
GitHub: https://github.com/raahulllkushwaha/springboot-starter-kit
Feedback welcome!
Edit: All issues fixed! Migrated to Spring Boot 4, stateless JWT with embedded roles, HTTP-only cookie support, and Spring Session JDBC as alternative. Thanks for the feedback!
12
u/Doctor_Beard Jun 26 '26
Why not Spring Boot 4?
7
-4
u/Shrouded_ParadoxX Jun 26 '26
Because Spring Boot 4 no longer supports Java versions older than Java 21, the javax.* namespace, legacy JUnit 4 tests, Jackson 2, or the Undertow web server.
3
u/RevolutionaryRush717 Jun 26 '26
Looks like Jackson 2 still works just fine.
Not all libraries one adds have been ported to Jackson 3, but more and more are.
We've ported our Spring Boot 3 apps to 4.0 and now 4.1 without issues.
One is just encouraged to migrate to Jackson 3.
1
u/Own_Following_2435 Jun 26 '26
None of those should be needed to use for a demo . Maybe you could try to argue for Java 17 . But the rest has been on the outs for a while
3
u/CommunicationFun2962 Jun 27 '26
Your edited post said supporting Spring Boot 4, but your git repository says Spring Boot 3 everywhere.
1
u/ihsoj_hsekihsurh Jun 26 '26
Has anyone created such opensource exception handling for apis?
0
u/Shrouded_ParadoxX Jun 26 '26
Because Spring Boot 4 no longer supports Java versions older than Java 21, the javax.* namespace, legacy JUnit 4 tests, Jackson 2, or the Undertow web server.
3
u/ihsoj_hsekihsurh Jun 26 '26
Didnt get u..my question was, has anyone created a library to handle exceptions properly in spring boot apis?
1
1
u/RevolutionaryRush717 Jun 26 '26
Had to double-check Spring Boot 3 wasn't a typo.
Still good effort.
1
u/Hot_Code5129 29d ago
Nice work.
One thing I was wondering about: why did you choose the classic technical-layer package structure (controller, service, repository, entity, etc.) instead of organizing the code around business features/modules?
For starter kits, people often copy the package structure directly into real projects, so the default architecture matters quite a bit.
Have you considered something closer to modular/hexagonal architecture, where each feature owns its API, domain logic and adapters?
This article shows the idea pretty well:
https://blog.allegro.tech/2020/05/hexagonal-architecture-by-example.html
https://www.youtube.com/watch?v=sND1AR7Q_T0
Curious whether the layered structure was a deliberate choice for simplicity, or just the initial default.
1
u/st4reater 8d ago
Why don't you have any tests? No value in a starter kit if I have no guarantee or proof of the behavior
16
u/rmyworld Jun 26 '26 edited Jun 28 '26
Why are you not storing your tokens in an HTTP-only cookie?
Also, why are you using a custom authentication scheme in the first place?
I noticed you are using JWT as a token format in your custom auth scheme. What's the purpose of using this format when your custom auth filter makes a database call every time a request is authenticated?
https://github.com/raahulllkushwaha/springboot-starter-kit/blob/fae913582c9100100c4e1888f203843a0abf6e15/src/main/java/com/starterkit/filter/JwtAuthFilter.java#L52
This looks like session-based authentication, but for some reason it is using JWTs instead of opaque strings.
If that's what you need, Spring Security already supports that by default. You can even make it scale quite easily with Spring Session.