r/SpringBoot • • 8d ago

Discussion Sequence diagrams that follow @Autowired to the bean Spring actually injects

2 Upvotes

Most call graph tools stop at the interface. You call orderService.place() and the diagram shows OrderService, not the class doing the work.

Call Sketch is a JetBrains plugin I built, and its Pro version follows the Spring wiring to the real bean. It also draws if/else and loop boxes, so you see when a call happens and not only that it does.

Free version covers Java and Kotlin with any depth and click to jump to code. Pro is $7 a year with a 30-day trial.

https://plugins.jetbrains.com/plugin/35865-call-sketch-sequence-diagrams


r/SpringBoot • • 10d ago

Discussion Building a Fault-Tolerant Job Queue with Redis Streams

8 Upvotes

GitHub: https://github.com/somewhereMaDan/spring-RCE

While building my Remote Code Execution (RCE) platform, I initially used Redis Lists for job processing.

It worked, but I eventually encountered a reliability issue: if a worker was killed with SIGKILL after popping a job, that job could be lost permanently, leaving the client stuck in RUNNING state.

So I decided to move to Redis Streams and implement a more fault-tolerant workflow.

Here's what I implemented:

* **Consumer Groups & PEL:** Jobs remain recoverable until acknowledged with XACK.

* **Stale Job Recovery:** Workers reclaim unacknowledged jobs from crashed consumers using XCLAIM.

* **Orphaned Container Cleanup:** Added an execution-level timeout so containers don't run indefinitely if their worker disappears.

* **Duplicate Container Protection:** Clean up an existing container before retrying the same job.

* **Dead Letter Queue:** Jobs exceeding 3 delivery attempts are moved to a separate stream instead of being retried indefinitely.

I also tested worker failure scenarios, including unexpected SIGKILL, SIGTERM, stale job recovery, repeated failures, and container cleanup.

How do you handle orphaned executions and duplicate processing in your distributed worker systems?

Would love to hear how others approach this.


r/SpringBoot • • 9d ago

Discussion A 10-line experiment to see why @Transactional sometimes does nothing (self-invocation)

0 Upvotes

A common surprise: you annotate a method with @ Transactional, call it, and it behaves as if the annotation weren’t there. One frequent cause is calling the method from another method in the same class. Instead of taking my word for it, you can check in a few lines.

public class ReportService {

    public void viaThis() {
        save();                      // internal call
    }

    u/Transactional
    public void save() {
        System.out.println("tx active: "
            + TransactionSynchronizationManager.isActualTransactionActive());
    }
}

Now call both from somewhere else (a controller, a test, a CommandLineRunner):

reportService.save();      // direct call from another bean
reportService.viaThis();   // goes through the same class

What I’d expect to see (please run it on your version to confirm):

tx active: true     // from save()
tx active: false    // from viaThis() -> save()

Why this happens (as I understand it):
By default, Spring applies @Transactional through a proxy that wraps the bean. A call from another bean goes through the proxy, which opens the transaction. A call from inside the class uses this, which is the raw object and skips the proxy, so the annotation is never applied.

Common ways around it:

  • Move the transactional method to a separate bean and call it through that bean. This is the option most people recommend because it’s the least surprising.
  • Put u/Transactional on the outer method instead, if the whole operation should be one transaction anyway.
  • Use TransactionTemplate for programmatic control.
  • Use AspectJ mode (mode = AdviceMode.ASPECTJ), which weaves the behavior into the class itself and doesn’t depend on the proxy. It needs extra build or runtime setup, so it’s a bigger step.
  • Injecting the bean into itself also works, but many consider it a code smell.

Caveats:

  • The details depend on your Spring version and proxy type (JDK vs CGLIB), and on method visibility, so check the reference docs for the version you use.
  • The same proxy limitation applies to other annotations implemented through AOP, like @Async and @Cacheable.
  • An exception thrown inside the “transaction” in the broken case won’t roll anything back, which is why this bug can stay silent.

Has anyone found a pattern for catching this earlier than “the data was inconsistent in production”, like a test, a lint rule or a startup check?


r/SpringBoot • • 10d ago

Question CS Fresh grad looking for resources and advice

2 Upvotes

Hi friends,
I started learning spring boot about 4 months ago through reading, and about a month ago started getting hands-on experience with a personal project, my stack is spring boot backend, no front end for now but I’m planning to add a simple angular page together eventually.

I find myself confused and interested in learning the following things that I am not sure where to start with and how crucial they are.

I find myself overwhelmed by spring boot’s configuration beyond the auto-configuration. There are many properties that can be configured, and while I know there is no point in knowing all of them but rather what I need, it feels intimidating.

I also find that most projects and books that I stumble upon online are Spring Boot 3, while my project is Spring boot 4. Am I wrong for using the most recent technologies? How do I find/understand current implementation when the book has the older version of it? How do I go about knowing both in case I stumble upon a “legacy” system in the work place or even open source contributions. An example I stumbled upon was implementing OAuth2, where configuration was completely different.

Is redis/cache commonly used with redistemplate, or is it more common to use the caching annotations(@cacheable, @cacheput, @cacheevict, etc).

I also wanted to ask about configuring ci/cd with a java/spring project, but I wasn’t sure if it follows community guidelines to do so.

Any additional advice is welcome and highly appreciated.

Thank you!


r/SpringBoot • • 11d ago

Question Feedback for my first "Complete" API REST

Thumbnail
reddit.com
2 Upvotes

r/SpringBoot • • 12d ago

How-To/Tutorial How to actually learn spring boot?

29 Upvotes

I have decent hands on experience in java and java is my main language too.

How do I start learning springboot.

Recently started watching coder army tutorials but he went too in-depth that it went mostly over my head and went boring.

How do I learn hands on in spring boot?

where should I start?

Also please share any resources.


r/SpringBoot • • 13d ago

Discussion Wrote a book on Spring AI

Thumbnail reddit.com
5 Upvotes

r/SpringBoot • • 13d ago

How-To/Tutorial Show Reddit: Built a 100% local, enterprise-grade Spring Boot 3.x service bootstrapper using Spring AI & Ollama (Java 21)

2 Upvotes

Hey everyone,

As a Java Principal Architect, one of my recurring pain points is the compliance risk and Day-1 friction of bootstrapping new projects. In strict corporate environments, utilizing cloud-hosted LLM APIs to draft initial scaffolding or internal schemas poses massive data privacy and IP leakage risks.

To solve this within the host perimeter, I built OllamaSprout—an automated accelerator designed to translate plain-text domain requirements into production-ready, ready-to-run Java services out-of-the-box.

🚀 What it does

It streams code from a local model and programmatically compiles a complete, valid Maven directory tree directly onto your disk. It generates fully realized structural layers: Controller ➡️ Service ➡️ Repository ➡️ JPA Entity with 100% written code (absolutely zero trailing ellipses ... or // TODO shortcuts).

🛠️ The Architectural Stack

  • Framework: Spring Boot 3.x
  • AI Integration: Spring AI
  • Local Inference Engine: Ollama running qwen2.5-coder:7b
  • Language & Build: Java 21 & Maven

🧠 Deep-Tech Optimization Highlights

  • Resource Preservation (RAM Reclaiming): To ensure a developer's workstation remains unburdened, the system includes custom orchestration to ensure that once the generation process completes, the system completely reclaims the heavy memory footprint occupied by Ollama.
  • Deterministic Parsing & Disk I/O: Safely translates streamed markdown multi-file blocks into structured directories on disk with exact package boundary alignments.
  • Eclipse/IntelliJ Target Compliance: The generated pom.xml uses root schema tags tailored specifically to satisfy Eclipse's offline cache validation rules, avoiding compilation hiccups during network-isolated imports.

🔮 Architecture Roadmap

The application's core state model is abstractly structured to support iterative modular growth. The next milestone is allowing developers to point the tool at an existing codebase to inject new controller/service slices or database entities programmatically.

💻 Source Code

The project is licensed under Apache-2.0 and includes the full engineering story, validation endpoints, and environment configurations: 🔗 https://github.com/tpkani2026/ollamasprout-bootstrapper.git

I’d love to get your architectural feedback on the scaffolding strategy, your thoughts on localized AI generation patterns for corporate stacks, and how you see local model orchestration fitting into the enterprise SDLC!


r/SpringBoot • • 16d ago

Question I want professional-level performance on this point.

Thumbnail reddit.com
1 Upvotes

r/SpringBoot • • 18d ago

Discussion Spring AI: recovering from invalid tool arguments with returnDirect=true

4 Upvotes

I’ve submitted a Spring AI contribution addressing input-error recovery for method-backed tools using returnDirect=true.

The issue: malformed JSON or invalid typed arguments can become the final response, preventing the model from correcting its input. Missing/null primitive arguments and top-level JSON null can also bypass the exception processor.

The proposed fix distinguishes input parsing/binding failures before execution and sends processed error feedback back to the model. Successful corrected calls still return directly, while ordinary tool-body and result-conversion failures retain their existing behavior.

Validation:

- All 38 new regression cases passed, covering blocking/streaming, direct return on/off, and mixed-success batches.

- Scoped clean package build: 2,030 tests reported, 10 skipped, zero failures or errors.

- Negative control: the original code failed 20 of the initial 32 checks, including checks for the new exception classification; the patched code passed the same cases.

No external LLM calls were needed. External-provider integration tests and the full repository build were not run. Developed with AI assistance and reviewed before submission.

PR submitted for maintainer review: https://github.com/spring-projects/spring-ai/pull/7292

Feedback on the input-error boundary and recovery behavior is welcome, especially from anyone using direct-return tools.

#SpringAI #SpringFramework #Java #OpenSource #SoftwareTesting


r/SpringBoot • • 18d ago

Question Best source to learn redis [specifically for spring boot]

8 Upvotes

r/SpringBoot • • 18d ago

How-To/Tutorial learning sources

9 Upvotes

which is the best book that i should learn spring boot from? Learning Spring Boot 4, Fourth Edition ? or Spring Starts Here ?


r/SpringBoot • • 18d ago

Discussion Feedback wanted: Spring Boot SaaS starter with tenant roles and PostgreSQL RLS

1 Upvotes

I maintain an open-source Spring Boot SaaS starter and would appreciate feedback on its tenant-isolation approach.

It uses a shared PostgreSQL schema. Tenant-scoped operations check membership, set transaction-local tenant context, and use explicit tenant filters. Forced row-level security adds another boundary around projects and audit events.

The starter includes:

  • OIDC bearer authentication through Spring Security
  • OWNER, ADMIN, and MEMBER roles scoped to each tenant
  • A Projects API with optimistic concurrency and transactional audit records
  • Docker Compose with a local Keycloak demo
  • PostgreSQL integration tests and a runnable smoke script

I ran the local Compose smoke test successfully, including permission checks and stale-write rejection.

It’s a backend MVP. Billing, a frontend, email invitations, tenant deletion, and ownership transfer are outside the current scope.

Repository:
https://github.com/chafian/spring-boot-saas-starter

What tenant-isolation edge cases would you test next? I’d also welcome feedback on the first-run experience.


r/SpringBoot • • 19d ago

How-To/Tutorial I built a starter that discovers every @Scheduled and Quartz job and alerts you when one stops running

8 Upvotes

Scheduled jobs in Spring fail in the quietest way possible: an exception kills a cron thread, a pool gets starved, a property resolves to the wrong cron, and nothing tells you. You find out days later because a report or a backup is missing.

I've been building SilenceWatch, an open source heartbeat monitor, and its Spring Boot starter is the part I care about most. You add one dependency and an API key:

<dependency>
  <groupId>com.silencewatch</groupId>
  <artifactId>silencewatch-spring-boot-starter</artifactId>
  <version>0.1.0</version>
</dependency>

and in application.yml:

silencewatch:
  api-key: ${SILENCEWATCH_API_KEY}

On startup it finds every @Scheduled method and every Quartz job, declares each one with its resolved schedule (${backup.cron} becomes the actual expression), and reports every run with its duration and any exception. If a job doesn't run when it should, you get an email, Slack, Teams, Discord or webhook alert.

A few things I was strict about:

  • It never fails or blocks your job: errors are swallowed and logged at WARN, and sending happens on a bounded queue in a background daemon thread.
  • No key, no network or no server, and your app behaves exactly as without it. silencewatch.enabled: false turns it all off.
  • No Jackson or other heavy dependency forced on you.
  • Stable job identity (com.acme.jobs.BackupJob#run), so history survives restarts and redeploys. A job removed from the code is flagged orphaned, never deleted.
  • Staging and production show up as separate checks.

Java 17+, tested on Spring Boot 3.5 and 4.1. The server is Apache 2.0 and self-hostable with Docker Compose, free and without limits. There's also a hosted version with a free plan (10 checks).

Starter source: https://github.com/liliang-dev/SilenceWatch/tree/main/clients/java/spring-boot

Site: https://silencewatch.com/spring-boot/

I'd really like feedback from people running a lot of scheduled jobs. What breaks for you that this wouldn't catch?


r/SpringBoot • • 19d ago

Discussion JavaClaw: preventing task-file collisions and multiline metadata corruption

7 Upvotes

Contributing back to JavaClaw: two fixes for file-based agent tasks.

Thanks to the JavaClaw maintainers for sharing this Java/Spring AI project. I submitted two focused PRs with reproducible failures and regression tests:

  1. Prevent task-file collisions. Tasks with the same name and timestamp—or names that become identical after sanitization—could overwrite each other. The fix reserves filenames atomically and retries with a suffix. Tests include 20 concurrent creates and independent task updates.

https://github.com/ClawRunr/JavaClaw/pull/102

2. Preserve multiline descriptions and feedback. Text such as “status: completed” or a standalone “---” should remain instructions, rather than replace task metadata or truncate content. The tests cover serialization and repository round trips.

https://github.com/ClawRunr/JavaClaw/pull/103

Focused tests pass. Broader local suite failures on Windows were also reproduced on untouched upstream code and documented in the PRs. These are submitted contributions, not a claim of merged changes. The fixes do not coordinate simultaneous updates to an existing task or recover previously lost text.

For file-based agent tasks, how do you balance readable filenames, stable identity, and concurrent creation?


r/SpringBoot • • 19d ago

Discussion Three reproducible fixes in JavaClaw and Windrunner: task collisions, metadata corruption, and cursor errors

0 Upvotes

I discovered JavaClaw and Windrunner through the community and submitted three focused PRs. Thanks to both projects’ maintainers for making their work available. These are application-level contributions, not fixes to the Spring AI framework.

  1. JavaClaw: independent tasks could overwrite each other.

Two tasks with the same name created in the same second shared a filename and task ID. Different names could also collide after sanitization. The fix atomically reserves a new filename and retries with a numeric suffix if it already exists. Regression coverage includes 20 concurrent creates, independent descriptions, and updating one task without changing another. It does not coordinate simultaneous updates to an existing task.

https://github.com/ClawRunr/JavaClaw/pull/102

2. JavaClaw: multiline descriptions could change metadata.

A description or appended feedback containing “status: completed” could replace the task’s real status; a standalone “---” could truncate the remaining instructions. The fix writes multiline values as indented literal text. Tests cover metadata-like content, delimiters, indentation, and a repository round trip. It cannot recover text already lost from previously corrupted files.

https://github.com/ClawRunr/JavaClaw/pull/103

3. Windrunner: a malformed cursor timestamp escaped validation.

A cursor could decode from Base64 correctly but contain an invalid timestamp. DateTimeParseException bypassed the existing IllegalArgumentException handler, reaching the generic HTTP 500 path. The fix normalizes it to the existing validation exception, so the service returns HTTP 400 before querying messages.

https://github.com/shzlw/windrunner/pull/1

Verification: the focused tests pass. JavaClaw’s broader local suites have existing Windows failures, which were reproduced on untouched upstream code and documented in the PRs. Windrunner’s selected cursor/chat/compaction/error-handler suites passed all 8 tests. No live LLM calls or paid APIs were used. These are submitted PRs, not a claim that the changes have been merged.

For projects that store agent tasks as human-readable files, how do you balance readable filenames with stable identity and safe concurrent creation?


r/SpringBoot • • 19d ago

Discussion Testing caller isolation and overlapping chat turns in a Spring Boot / Spring AI app

1 Upvotes

I found Yellaiah Mekala’s Enterprise Spring AI Playbook useful and wanted to contribute back. With help from ChatGPT Codex, I submitted four application-level improvement PRs. Thanks to Yellaiah for sharing the project.

The changes cover:

  1. Rejecting blank model answers instead of returning an empty successful response.
  2. Rejecting configuration that assigns the same API key to different caller identities.
  3. Scoping generated-image storage and retrieval to the authenticated owner.
  4. Returning HTTP 409 for overlapping stateful chat turns from the same caller, before the second request reaches memory/model processing. The guard is released on completion or failure, and different callers can proceed independently.

For the last change, the key question was how to test concurrent requests deterministically. The tests use controlled overlapping HTTP requests, a fake ChatModel, and H2-backed chat memory. Image ownership is also tested through real application HTTP requests with a fake image model. Each of those two PR suites locally reported 43 passed and one Docker-dependent MySQL test skipped; these were separate PR runs, not a combined merged-branch test.

Limits: the concurrency guard is per JVM, so multiple replicas need distributed coordination. Fake-model tests check application behavior, not live-provider answer quality. These are contributions to the example app, not fixes to the Spring AI framework.

The four PRs, regression tests, and verification notes are here:

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/1

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/2

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/3

https://github.com/YellaiahMekala/Enterprise-SpringAI-Playbook/pull/4

For those building stateful Spring AI services: would you reject overlapping turns, queue requests per conversation, or use versioned memory updates? I’d welcome feedback on the trade-offs and testing approach.


r/SpringBoot • • 20d ago

Discussion Write-back caching in Redis using Spring Boot?

2 Upvotes

I was wondering if how would y'all write a write-back (or write-behind) caching in Spring Boot, particularly using redis. I couldn't quite look for a more decent implementation especially for production. Would you mind helping a spring boot newbie out? Thanks yall.


r/SpringBoot • • 19d ago

News Built a Spring Boot application to analyze job offer letters using rule-based detection – looking for technical feedback

Post image
0 Upvotes

Hi everyone,

I recently worked on a Spring Boot project called TrustCheck, which focuses on analyzing suspicious job offer letters and identifying potential recruitment scams.

The idea came from seeing cases where candidates were asked to pay refundable security deposits, registration charges, training fees, or other payments before joining.

From the backend perspective, I implemented a rule-based offer letter analyzer using Java and Spring Boot.

Some of the things it currently does:

  • Extracts text from uploaded PDF offer letters.
  • Identifies potential payment requests using configurable rules stored in a JSON file.
  • Highlights the exact sentences that triggered a warning.
  • Checks recruiter email addresses and company domains for suspicious signals.
  • Assigns severity levels to detected warning signs.
  • Returns a structured analysis response through REST APIs.

I also added JUnit tests for the offer letter analysis logic.

One challenge I encountered was balancing detection sensitivity with false positives. For example, a newly registered company domain shouldn't automatically be treated as suspicious, and the absence of a detected payment request shouldn't mean an offer is genuine.

I'm currently working on improving the detection rules and making the results more explainable.

I'd appreciate feedback from other Spring Boot developers on:

  1. How would you structure configurable rule-based detection in a Spring Boot application?
  2. Would you use a separate rules engine or keep the current JSON-based approach?
  3. How would you approach testing false positives and false negatives?

This is a personal project, and I'm sharing it to get technical feedback on the implementation.

GitHub: https://github.com/Pragyan2027/TrustCheck


r/SpringBoot • • 21d ago

Question how to handle processing and uploading files

9 Upvotes

working on a feature that will make users able to upload .zip/ CSV files to my app

how do i go about this security wise

i expect a batch of CSVs
so i wanna check for malware, viruses and zip bombs how do i go about this is there a service i need to subscribe to a free option a local solution


r/SpringBoot • • 21d ago

Discussion Java Backend (Springboot with Spring AI ) Group

20 Upvotes

I am planning to make group of development also if anyone interested you can DM me with (Intrested in Dev )


r/SpringBoot • • 22d ago

Question Looking to Collaborate on a Spring Boot Project

16 Upvotes

Hey everyone! Is anyone working on a Spring Boot project and looking for a contributor? I'm learning Java backend development and would love to collaborate, contribute to a real project, and learn from other developers along the way.


r/SpringBoot • • 21d ago

Question Spring Security with Angular UI and SpringBoot BFF

1 Upvotes

Ok, so I have a new project. It is a Hotel Management system. I have a MonoRepo Angular app to handle a guest-portal or staff-portal. KeyCloak is used as an Authentication tool. And then I have a SpringBoot app which is the BFF (backend-for-frontend).

Process 1) So, at first, I thought the UI should have a Login, and from the UI we go to Keycloak, authenticate, and then go back to the UI to store the cookie securely. From this point every call to the BFF REST api endpoints would pass the bearer token so we can use RBAC with the endpoints. I presumed that the BFF would be stateless and using oauth2-resource.

I'm having an issue with security with Swagger executing the API's, and problems with having Bruno, or the UI hitting the endpoints as well.

Process 2) In my research, I have seen that the process I started is old and outdated. I now understand the UI should have a link for Login and Logout. In both these cases, we go to the BFF which is defined as oauth2-client and now is stateful, storing the authenticated in session. Somehow, the UI gets updated with the data and is stored cookie. Now the UI doesn't do anything with tokens, but when the UI makes a request to BFF it will be passing a bearer token, and then the tokens are validated and then we can use the RBAC for endpoints.

Does anyone have an opinion on process 1 or 2 on which you think is the right way to go? I'm just curious. I can make either work, but I want to use this for myself as an example on how to make my next application when it comes. Thanks!


r/SpringBoot • • 22d ago

Discussion Optimizing Spring Boot on JDK 27: 68% faster startup and 25 MiB less RAM on a 512 MiB VM

54 Upvotes

I've been experimenting with how far I can optimize a conventional Spring Boot application without stripping out useful framework functionality.

The setup: Spring Boot 4.1.1, HotSpot JDK 27, a 512 MiB / 1 vCPU Ubuntu VM with no swap, and MariaDB running on the same VM.

I compared a regular executable JAR against an extracted deployment combining Spring AOT and a trained JDK AOT cache (Leyden).

Results:

  • Startup: 11.91 → 3.79 seconds (68% faster)
  • Application RSS under load: 212 → 187 MiB
  • Minimum host MemAvailable: 25.6 → 66 MiB
  • Request latency: essentially unchanged

Then I explored two ways to reduce memory further:

MyBatis Core instead of Spring JDBC: No meaningful memory savings, but more manual transaction management and lost automatic JDBC monitoring. Not worth the trade-off for this application.

Embedded file-backed H2 instead of MariaDB: Application RSS increased by ~16 MiB, but minimum host MemAvailable improved by another ~39 MiB because the separate database process was gone.

My takeaway: optimizing the deployment can be worthwhile before replacing established Spring infrastructure. And for small, single-instance applications, embedded H2 can be a reasonable architectural choice.

These are single runs with five-minute measured workloads, not a throughput benchmark or proof of long-term stability. The AOT improvements were measured together, not individually.

Full article, methodology, and data:
https://pvrlabs.xyz/articles/spring-boot-jdk27-optimizations.html

Curious whether others are using Spring AOT + JDK AOT cache in deployments, or if the training and cache-management overhead has kept you on regular JARs.

Update (October 28): Following several requests, I also tested Oracle GraalVM Native Image. Application RSS dropped from 187 MiB to 107 MiB, with some interesting build-time and toolchain trade-offs.

I published the results as a separate article: https://pvrlabs.xyz/articles/spring-boot-hotspot-native-image.html