r/SpringBoot • • 6h ago

Question Is Spring needed in this situation ?

0 Upvotes

I m currently new to Spring and learning important concepts related to this but one thing stick in my mind imagine we have 1000 classes and just a hypothetical situation that all of them somehow is independent classes there is no dependency injection at all is there spring needed in this situation at all ?


r/SpringBoot • • 4h ago

Question Spring AI's validateSchema() catches malformed output.

0 Upvotes

I've been working on LLM extraction in Spring Boot services (invoices, forms, that kind of structured data), and kept hitting the same issue.

Spring AI 2.0's `validateSchema()` is great: it checks the response against the record's JSON schema and retries with the error if it fails. But the bugs that actually hurt me passed that check:

- A line item silently dropped, so the rows no longer added up to the total

- A value that never appeared anywhere in the source document

- Correct output on Monday, slightly different output after a prompt tweak on Friday

The JSON was valid and deserialized cleanly into my record every time. The data was just wrong.

Using a second LLM as a judge in tests felt like the wrong fix: slower CI, token costs, and tests that don't give the same verdict twice.

So I started writing deterministic checks as plain JUnit tests instead:

- Cross-field arithmetic with BigDecimal (parts must sum to totals)

- Provenance: extracted values must actually appear in the source

- Latency and cost budgets per call

- A golden set of JSONL examples that runs on every PR, so a prompt or model change shows up as a failing build

I ended up packaging this as an open-source library, Outputgate (on Maven Central, works alongside Spring AI rather than replacing anything). One known limitation: provenance matching is currently verbatim, so `1,200.00` vs `1200` can fail correct output. Normalized matching is what I'm working on next.

Repo: https://github.com/ravismash/outputgate

But I'm mostly curious how others handle this:

  1. Do you test LLM output correctness in CI at all, or only at runtime?

  2. Are you using LLM-as-judge evaluators, hand-written checks, or something else?

  3. What's the worst "valid but wrong" output you've caught?


r/SpringBoot • • 12h ago

Discussion Transactional Outbox is harder than you think

20 Upvotes

I had to write a transactional outbox for two of my projects. The popular solutions didn't fit, and CDC with Debezium felt too heavy for "save an event together with the data, send it later".

We all know things often look simpler on paper than in reality, right? What's there to do, really? Just write to a table, poll it, publish the messages - easy, right?

Not so fast. Building a production outbox is like growing a stalactite: it slowly accretes features, scripts and workarounds. So I want to share my hard-won solution, which I wrapped into a simple, fairly compact, ready-to-use starter that has (I hope) everything you need.

Guarantees (with caveats):
- At-least-once delivery with retries and backoff.
- Effectively-once processing through an inbox (deduplication on the consumer side).
- At-most-once processing through the inbox, for side effects like emails where a duplicate is worse than a miss.

Two design decisions I’m happy with:
- Adaptive polling. While an event type has nothing to send, the pause between polls grows up to a maximum, and drops back to the minimum as soon as events appear. This noticeably reduces DB load.
- Per-event-type settings. Each type has its own poll interval, batch size and retry count. Critical events go out within a fraction of a second, while reports can wait a few minutes when there’s no activity.

Repo: https://github.com/dmitriy-iliyov/oncebox

Feedback is very welcome. If you’ve built an outbox in Spring yourself, what was your biggest pain point?


r/SpringBoot • • 4h ago

Question Recommendations for Spring Cloud AWS

3 Upvotes

Hey everyone. I’m looking for some recs on learning spring cloud aws for work. I am a new backend dev for my team that heavily utilizes microservice apps written in Java and uses Spring as a framework. I’ve been working through the latest version of spring start here and it has been helpful to a degree. I understand the basic flow between building APIs that interact with some persistent data source and return results back to the client but I noticed a large chunk of our services interact with aws services such as S3, SNS, SQS and other stuff like opensearch. I do not know much on development with these services. I have used s3 before for a previous job and understand high level of sqs/sns but I don’t know how they interact with the apps we maintain. I try to review our code and see if I can make sense of it but I am having a hard time distinguishing our custom logic with Spring’s so I am looking for recommendations that would allow me to teach myself on them. For now , the services I mentioned : S3, sqs, sns and open search are top priority as those are the services that I know we interact with the most. I have not had much interaction with the apps that utilize those since I am still newer and haven’t had much on my plate but I want to be prepped enough to at least diagnose what is occurring in the code when it comes down to it. Thank you!


r/SpringBoot • • 5h ago

How-To/Tutorial JPA vs Hibernate vs JDBC: What Each One Actually Does | Visually Explained

Thumbnail
youtu.be
3 Upvotes

Hey everyone,

I made a video for anyone who uses Spring Data JPA but still isn't sure what JPA, Hibernate and JDBC each do, or how they differ.

It's visually explained. It follows one save() call from a Spring Boot app down to the database, so you can see what happens behind the hood and where Hibernate comes from. It's about 11 minutes.

Hope it helps someone, and tell me if anything is unclear . Thank you for the support as always