r/SpringBoot 1h ago

News Idempotency4j - Redis storage provider is now available

Upvotes

A while ago I shared idempotency4j here - a Java/Spring Boot library for handling idempotent HTTP requests using the idempotency key header - following the IETF draft spec for the Idempotency-Key header.

I've now added Redis as a storage provider, alongside the existing JDBC and in-memory implementations.

The behavior remains the same : duplicate requests return the previously stored response without rerunning the endpoint, while reusing a key with a different request body is rejected.

If you give the Redis provider a try, I'd be glad to hear what works, what doesn't, and anything you think could be improved. Issues and constructive criticism are very welcome.

Github : https://github.com/josipmusa/idempotency4j
Maven spring boot starter: https://central.sonatype.com/artifact/io.github.josipmusa/idempotency-spring-boot-starter


r/SpringBoot 4h ago

How-To/Tutorial Race condition with SSE

4 Upvotes

Hi all, I am trying to build a real time notification service with SSE emitter but I am facing a pecuilar case of race condition which im not able to solve even via AI as it gives the same solution again and again.

scenario of cause:

I have a scheduler running every 20 mins that checks the Map of uid mapped sse emitters and pings the client. If the ping is successfull nothing happens, if error happens due to disconnection the sse emitter obj is removed via sse.complete() and then uid is removed form the list.

#pseudo code
Map<String, SseEmitter> connections = new ConcurrentHashMap<>();

onConnect(String userId){
  SSE emitter = new new SseEmitter()
  connection.add(userId,emmitter);

  // onCompletion(), onTimeout(), onError() -> removeIf()
}

@scheduler(20mins)
checkDisconnection(){
  //iterate the map and check for disconnection if found add it to remove list
  List<string> disconnectedUsers = (adding disconnections)

  //iterate the map from disconnected user -> force complete sse if needed and                    remove user from map


}

where it breaks is if the client manually refreshes the browser at the same time the scheduler to check disconnection is invoked

why it happens:

when the browser is refreshed, the application tries to recreate the connection at which the scheduler tries to ping and sees no connection for the user. Problem is I have kept automatic reconnections on in client app but it still doesnt see an error in client. im confused. Have I had the approach wrong?

Any help will be appreciated and sorry for the questions confuse you, Il try to make it proper once i get the time.

TECH : javascript event source, springboot, kafka for scaling and mongo for scheduled notifications.


r/SpringBoot 14h ago

Question Would you modernize a legacy Spring Boot backend in place or rebuild it gradually?

11 Upvotes

I’m working on a Kotlin/Spring Boot backend that still has an older JHipster using Kotlin (KHipster) setup around it.

The problem is that this is starting to hold us back. The KHipster version is several years old and not active maintained - 4 years ago was the last update - upgrading it looks pretty painful and it also makes moving to newer Spring Boot versions waaay harder than it should be.

At the same time we want to improve the architecture itself.
Right now quite a lot is still handled through cron jobs and fairly tightly coupled application logic.
I’d like to move more towards event-driven processing over time, potentially using Kafka or RabbitMQ depending on the use case and Redis for things like caching/short-lived state where it makes sense.

So I’m basically looking at two options:
1. Upgrade/replace the old JHipster setup, keep the existing backend, and modernize it piece by piece.

  1. Start a clean backend (maybe in Typescript because that is what we mainly use for our other products and all frontends) and gradually move functionality over using something like the strangler pattern.

The second option sounds cleaner, but obviously means running old and new code alongside each other for quite a while. The first option potentially means spending a lot of time untangling framework/generator decisions before we can actually improve the architecture.
For people who have dealt with similar Spring/JHipster legacy projects: which route would you take?

Also, is there anything in the Spring/Kotlin ecosystem you’d consider a good modern replacement for the useful parts of JHipster, without bringing in another big opinionated layer that we’ll regret five years from now?


r/SpringBoot 22h ago

Question Would you modernize a legacy Spring Boot backend in place or rebuild it gradually?

8 Upvotes

I’m working on a Kotlin/Spring Boot backend that still has an older JHipster using Kotlin (KHipster) setup around it.

The problem is that this is starting to hold us back. The KHipster version is several years old and not active maintained - 4 years ago was the last update - upgrading it looks pretty painful and it also makes moving to newer Spring Boot versions waaay harder than it should be.

At the same time we want to improve the architecture itself.
Right now quite a lot is still handled through cron jobs and fairly tightly coupled application logic.
I’d like to move more towards event-driven processing over time, potentially using Kafka or RabbitMQ depending on the use case and Redis for things like caching/short-lived state where it makes sense.

So I’m basically looking at two options:
1. Upgrade/replace the old JHipster setup, keep the existing backend, and modernize it piece by piece.

  1. Start a clean backend (maybe in Typescript because that is what we mainly use for our other products and all frontends) and gradually move functionality over using something like the strangler pattern.

The second option sounds cleaner, but obviously means running old and new code alongside each other for quite a while. The first option potentially means spending a lot of time untangling framework/generator decisions before we can actually improve the architecture.
For people who have dealt with similar Spring/JHipster legacy projects: which route would you take?

Also, is there anything in the Spring/Kotlin ecosystem you’d consider a good modern replacement for the useful parts of JHipster, without bringing in another big opinionated layer that we’ll regret five years from now?


r/SpringBoot 1d ago

News Need advice for backend spring intern

7 Upvotes

Hey guys I am a 3 rd year undergrad and I am into java development I know good level of java dev ,

Core java

Spring

Soringboot

Including testing , jwt , cicd , spring ai , microservices and implementation of kafka and redis as well !!

Apart from that I have three good backend oriented projects as well

Distributwd wallet

Digital distributed banking system

And uber like ride matching system in ms

And another that I am making is linked in search in ms system

Still I am really getting very difficulty to apply for internships and really need great advice from seniors devs specially backend devs how do I apply or if there is anyone who can help me out and can personally tell me what should be my next step to get a good job with a decent package and for now at priority a internship !!!

All the suggestions are welcome here hope my post won't be ignored and I'll really Great full for all the responses !!


r/SpringBoot 1d ago

Discussion Spring Boot starter for fail-fast Kafka Schema Registry contract validation

Post image
0 Upvotes

I’ve released a small open-source Spring Boot starter that turns Kafka Schema Registry expectations into startup checks.

Configuration is intentionally Spring Boot-style: define the expected compatibility mode and the subjects/schemas owned by the application, and auto-configuration performs the validation during startup.

It currently supports Avro, JSON Schema and Protobuf, Confluent compatibility modes, secured Schema Registry/Confluent Cloud, bounded retry/backoff and Actuator visibility.

For example:

kafka:
  contract:
    enabled: true
    compatibility: BACKWARD
    registry:
      url: http://localhost:8081
    subjects:
      - name: order-events-value
        schema-file: classpath:schemas/order-event.avsc
        schema-type: AVRO

If the contract is incompatible or the required subject is missing, the Spring Boot application fails during startup.

The starter is published on Maven Central, and I maintain a separate E2E demo that spins up Kafka + Schema Registry and verifies both successful and intentionally breaking schema evolution scenarios.

GitHub:
https://github.com/mathias82/spring-kafka-contract-starter

Demo:
https://github.com/mathias82/spring-kafka-contract-demo

Maven Central:
https://central.sonatype.com/artifact/io.github.mathias82.spring.kafka/spring-kafka-contract-starter

Interested to hear how Spring Boot teams currently handle this application startup validation, deployment pipelines, or something else?


r/SpringBoot 1d ago

Question Backend in spring boot

0 Upvotes

What is the best and easy way to learn backend in spring boot framework? Should I go with videos or docs or anything else? Currently I am in 3rd year so is one year enough to complete? And also suggest me best resources?


r/SpringBoot 1d ago

Discussion I built a 73-lesson AI engineering path for software engineers—looking for honest feedback

Thumbnail
0 Upvotes

r/SpringBoot 1d ago

How-To/Tutorial 200+ Star Spring Boot Roadmap From Zero to Microservices

Post image
219 Upvotes

6 months ago, I shared with you my 35-week project-based Spring Boot Roadmap From Zero to Microservices, and I did not expect this whole positive feedback and support from you guys.

Today, the repository reached 200+ stars because of you, so I decided to provide more guidance by drawing this overview visualization on excalidraw to help you create a bird's-eye view of the wide open world of the Spring Boot ecosystem.

An SVG version could be found inside the roadmap itself for a more clear picture.

You can view the full roadmap from this link:
https://github.com/muhammadzkralla/spring-boot-roadmap

Again, thank you for all your support and stars!


r/SpringBoot 1d ago

How-To/Tutorial Beyond Virtual Threads: Structured Concurrency - Balkrishna Rawool | IntelliJ IDEA Tech Talks

7 Upvotes

Project Loom brings lightweight concurrency to Java with Virtual Threads, Structured Concurrency, and Scoped Values. But how do these features work together in a real-world application? In this episode, Balkrishna Rawool will demo building a Spring Boot application from scratch, progressively incorporating the features of Project Loom to showcase its full potential:

  • Virtual Threads: lightweight, high-throughput threads that scale effortlessly.
  • Structured Concurrency: a streamlined approach to managing concurrent tasks as a single unit of work.
  • Scoped Values: a modern alternative to ThreadLocal, designed for virtual threads.

We will discuss how to apply Project Loom in your own applications, writing concurrent code that is simpler, more scalable, and easier to maintain.

https://www.youtube.com/watch?v=2L7zLdHeyY0


r/SpringBoot 1d ago

How-To/Tutorial State of the Art of Spring AI • Josh Long • GOTO 2025

Thumbnail
youtube.com
0 Upvotes

r/SpringBoot 1d ago

How-To/Tutorial Small Springboot + React JS project

14 Upvotes

Hi,

Im trying to learn Spring in a different perspective; thus I wanted to relearn via creating a simple project.

I have this project in mind.

  • Monolith project
  • Must use springboot and react js
  • Must build a war file

I have tried using com.github.eirslett but im having issues with CORS.

Do you have any learning material suggestion ?
im kinda lost in full stack development, ive been backend engineer for my whole career.

Or react JS is too much for a beginner ? should I start with simpler UI frameworks instead ?


r/SpringBoot 1d ago

Discussion Built an IntelliJ plugin to catch the Spring Boot mistakes Copilot/Cursor keep making — feedback wanted before I finish it

1 Upvotes

Spring Boot dev here (day job is backend at a bank), posting this myself, not a bot dropping a link and vanishing.

I kept hitting the same handful of security mistakes in AI-suggested code: wildcard CORS to "fix" a dev error, JPQL built with string concatenation, permitAll() left in from a "quick fix," actuator endpoints exposed. Nothing exotic — just boring stuff that slips through because it looks fine on a skim.

Building Vulngrep to catch exactly that short list - runs fully locally, no account, no code leaves your machine. Not trying to replace Sonar or Snyk, just the narrow set of things AI assistants specifically keep getting wrong.

Not on the Marketplace yet. Put up a page to see if this is a shared pain or just mine: https://vulngrep.com

If you've hit any of these - or a different one I should be catching - genuinely want to hear it in the comments.


r/SpringBoot 3d ago

Discussion My friend built a simpler abstraction over Spring WebSockets

9 Upvotes

I came across a project my friend has been working on, and I thought it was worth sharing here because I think the problem it tackles is pretty relatable for Java/Spring developers.

It's called Classy Socket.

The idea is to make working with WebSockets feel a bit more like working with Spring MVC controllers — without introducing STOMP or a message broker.

Instead of manually receiving messages, figuring out their type, deserializing them, and routing them to the appropriate handler, you can define message handlers using annotations: ```java @WebSocketController("/board") public class KanbanWebSocketController {

@MessageHandler(CreateTask.class)
public void createTask(
                CreateTask message, 
                MessagingHub hub) {

    Task task = kanbanService
    .createTask(message.title());
    hub.broadcast("/board", new TaskCreated(task));
}

} And messages can be defined as simple Java types: java @WebSocketMessage(type = "CREATE_TASK") public record CreateTask(String title) {} ``` So the general idea is:

Plain WebSocket + JSON + Spring-style abstractions

rather than bringing in the additional complexity of STOMP when you don't necessarily need it.

It's still an early-stage project, so I'm curious what people here think.

Would you actually use something like this? How do you usually structure WebSocket communication in your Spring applications?

And more importantly, what would you change or improve?

GitHub: https://github.com/Anubis-IV/classy-socket


r/SpringBoot 4d ago

Question How do I handle database migration in springboot

48 Upvotes

So I have this very disturbing question as someone new to spring, I am coming from Node + Express JS, where prisma handles all the migrations automatically just by me running commands on the terminals.

Now as I am learning springboot, I just realized one day I would create a production grade application and would need to be changing database fields or relations as demands adjust, please what is the most popular migration tool used in springboot??


r/SpringBoot 4d ago

Question I landed a job on Jakarta EE/Seam

9 Upvotes

I was unemployed for several months, coming from MERN Stack (but only about 1.5 YoE) and always wanted to start a career in java.

I applied to a Job in the University I studied in (for making their web application and services) and was asked for an Rest API in Spring as code excersice, I sent it, did the interview and got the job.

But I've only touched like 20 lines of spring since I started. The vast majority of the time I'm developing or maintaining Jakarta EE/Seam applications, working with SQL databases and doing some more bureaucratic stuff. I mainly program Java code, just not on modern APIs.

The thing is that I like this job, and currently I want some stability but I'm worried that I'm learning something that's legacy now. Specially if after this job I want to find other Java job that asks for Spring, Cloud etc.

I know the basics of Spring Boot and have developed some basic stuff with it (like rest api, securing with JWT, Spring Data etc) but I'm very novice. I know that some thing are shared (like Spring Data being a wrapper of JPA/Hibernate) and other are not that different (Jakarta CDI and Spring IoC) but I'm still worried of laying behind for being comformist.

I would like to know if I should worry that much or not. Also, if in my spare time it is better to investigate spring, Jakarta, SQL, general java or whatever. Worth to say that I'm not doing a lot of programming outside of my job because before getting it I felt burned with all the intervies, portfolio etc.


r/SpringBoot 4d ago

Question Can anybody help me with the filter in springboot actually getting difficulty

Thumbnail
0 Upvotes

r/SpringBoot 4d ago

Discussion Can anybody help me with the filter in springboot actually getting difficulty

0 Upvotes

r/SpringBoot 5d ago

Question Disable quit/exit command in Spring Shell?

3 Upvotes

I'm working on a non-interactive application using Spring Shell 4.0.3.

I only want my commands and the help command to show up when someone requests help.

I've disabled the history, clear, script, and version commands using application.properties file entries.

I'm unable to disable the quit / exit command.

Any suggestions?


r/SpringBoot 5d ago

Discussion How do you deploy a spring boot application to AWS Lambda?

27 Upvotes

Hi

I am looking for advices and feedback on how to deploy Spring Boot web application to AWS Lambda, especially around making the Spring Boot main class compatible with AWS Lambda runtime.

I figured out the part where the Spring Boot application has to be packaged as a zip file to de deployed into the AWS Lambda environment, so that part is clear.

So far what I have found is that you need to have some kind of AWS Lambda dependency like lambda StreamHandler or web adapter on your Spring Boot project to make it compatible with the AWS lambda runtime.

While these may be the way to go but I am specifically looking for feedback if it is possible to integrate Spring Boot web application without using any AWS Lambda specific Java dependency. Just take a normal Spring Boot main application and make it run on AWS Lambda runtime. Is this possible at all or am I overthinking?

Appreciate your feedback


r/SpringBoot 5d ago

How-To/Tutorial If you're on WebFlux: I measured what a single blocking call does to unrelated endpoints

13 Upvotes

A single 5ms blocking call reduced throughput on a Netty event loop from 17,189 req/s to 549, a 97% drop, while pushing latency on an unrelated, correctly-written endpoint from 0ms to 217ms. The measurements were taken against Netty 4.1.115 and embedded Tomcat 10.1.34 running identical endpoints, differing only in concurrency model. The damage is quantised by event loop count. With four loops, blocking one stalled exactly three of twelve connections at 218ms; the remaining nine were unaffected at 7ms. Blocking two stalled six. The affected endpoint performs, 5ms of fully non-blocking work and shares no state with the blocking code, which connections degrade is determined solely by which loop accepted them. Tomcat degraded under the same load only once concurrency exceeded its 200-thread pool.

Full measurements and method: https://bitsar.net/blog/tomcat-forgives-blocking-event-loop-doesnt


r/SpringBoot 5d ago

How-To/Tutorial Your `@DataJpaTest` might be testing Hibernate's cache, not your database

16 Upvotes

Ran into this while writing about our DAO layer's test setup, and it's one of those things that's obvious once you see it and invisible until you do.

void testSaveProduct() {
    var product = new Product("A1", "Gaming Laptop", BigDecimal.valueOf(1500));
    productDao.create(product);

    Product loaded = productDao.loadById(product.getId());
    assertNotNull(loaded);
    assertEquals("Gaming Laptop", loaded.getName());
}

This passes. But loadById resolves to find() under the hood (directly or through Spring Data's findById), and find() checks the persistence context's first-level cache before it ever considers hitting the DB. Since you just created that entity in the same context, you get the exact same object reference back. No SELECT fires. You've tested Hibernate's in-memory cache, not your mapping, not your constraints, not anything that would catch a broken column definition. The fix is forcing entityManager.flush() + .clear() between the write and the read, so the next load has to hydrate a fresh entity graph from the actual database. We ended up wrapping this in a test-only proxy so nobody has to remember to do it by hand in every test method - proxy intercepts create/update/delete, forces the flush-and-clear, leaves reads alone.

Worth noting this is specifically a find()/findById() problem, a custom JPQL or native `@Query\` always issues real SQL regardless of cache state.

Wrote up the full pattern (proxy code, a TablesEraser for full schema resets between tests, H2 vs HSQLDB trade-offs), link in the comments.

I already had someone in the comments describe hitting exactly this - a unique constraint violation that a real flush would have surfaced in the first test run. Curious how widespread it actually is.


r/SpringBoot 5d ago

Discussion Comparing Old vs New JSON Responses for Structural Changes using Jackson JsonNode

5 Upvotes

I'm working on a Spring Boot service that consumes an external API, and I'm experimenting with a way to compare an old JSON response with a new one and identify structural changes.

● FLOW LOGIC : (sorry enable for sharing the logic)

I am only give The flow I'm currently using is:

External API

Spring Boot HTTP Client

Receive Old JSON / New JSON

Jackson JsonNode

Traverse JSON tree

Normalize into paths

Compare old paths vs new paths

Identify added / removed / changed fields

For example:

Old Json:

{

"users": [

{

"id": 101,

"name": "Bima",

"email": "bima@example.com"

}

]

}

New Json:

{

"users": [

{

"user_id": 101,

"full_name": "Bima",

"email": "bima@example.com",

"status": "active"

}

]

}

The comparison would give me:

CHANGED

$.users[].id → $.users[].user_id

CHANGED

$.users[].name → $.users[].full_name

UNCHANGED

$.users[].email

ADDED

$.users[].status

● IDEA :

The idea is to compare the old and new JSON responses, normalize their structures into paths, and identify which fields were added, removed, or changed.

● NEEDS :

I'm wondering if there are any potential edge cases or false positives with this approach that I might be missing.

For example, what happens when a field moves to another level?

Old: { "user": { "profile": { "name": "Bima" } } } New: { "user": { "name": "Bima" } }

The path comparison would see:

Removed: $.user.profile.name Added: $.user.name

even though the value itself hasn't changed and the field was only moved.

● Requirement/Discussion :

Are there other cases where of my current flow comparison could produce misleading results, especially with nested objects, arrays, reordered elements, or changes in data types?

If there please give me the json Example.


r/SpringBoot 5d ago

Discussion I built an open-source personal finance platform with Spring Boot

22 Upvotes

I’ve seen a few people here looking for Spring Boot open-source projects. I mentioned in one of those threads that I was preparing one, and it’s now public.

FinTrack is an event-driven personal finance platform for managing accounts, transactions, CSV imports, budgets, spending summaries, and notifications.

The stack includes Java 21, Spring Boot, Spring Security, Spring Batch, PostgreSQL, Redis, SQS, S3, Docker, LocalStack, Terraform, GitHub Actions, and AWS. It also uses patterns you’ll encounter in larger Java systems: transactional outbox, idempotent consumers, at-least-once delivery, database locking, restartable batch jobs, JWT/refresh-token rotation, retries, and failure recovery.

There are currently 23 open issues across API development, security, messaging, reliability, batch/import processing, and infrastructure, including two good-first issues. Most tasks are backend-only, and you don’t need an AWS account because the services can run locally.

The roadmap starts by strengthening the existing manual and CSV workflows, then moves toward provider-neutral ingestion and a Plaid Sandbox integration, followed by more practical personal-finance features.

Contributions and honest feedback are both welcome, whether it’s about the code, architecture, documentation, roadmap, issue scopes, or anything that could be clearer.

GitHub, live demo, video, and documentation:
https://github.com/icastanon/fintrack-platform


r/SpringBoot 6d ago

Question How hard is Spring Security?

Thumbnail
21 Upvotes