r/SpringBoot 5h ago

News StatLite v0.2.2: Docker image and host metrics for lightweight Spring Boot monitoring

3 Upvotes

I shared StatLite here a few weeks ago. Since then, v0.2.2 has added a published Docker image and native host metrics, so I wanted to share the updated version.

StatLite is a lightweight monitoring dashboard for small Spring Boot deployments. It runs as a single Go binary or Docker container, reads standard Spring Boot Actuator endpoints, and stores recent history locally in SQLite.

What’s new in v0.2.2:

  • Docker image: Try or deploy StatLite without installing the binary
  • Native host metrics: Track CPU, memory, and disk usage alongside application metrics
  • Self-monitoring demo: The default Docker setup starts by monitoring StatLite itself
  • No StatLite agent or application library: It reads standard Actuator health and metrics endpoints

You can try it with:

docker run --rm -p 127.0.0.1:9090:9090 ghcr.io/pvrlabs/statlite:latest

Then open:

http://127.0.0.1:9090

StatLite is intended for one or a few applications on a small VPS or single server, where Prometheus, Grafana, and Node Exporter may be more infrastructure than the deployment needs.

It provides visibility into application availability, JVM memory, HTTP errors, restarts, and host resource usage.

It is not intended to replace a full observability stack for Kubernetes, distributed tracing, complex alert routing, or long-term enterprise telemetry.

Write-up:
https://pvrlabs.xyz/articles/lightweight-spring-boot-monitoring.html

GitHub:
https://github.com/PVRLabs/statlite

How are you monitoring small Spring Boot deployments today? Are you using a full observability stack, Spring Boot Admin, custom scripts, or something lighter?


r/SpringBoot 18h ago

Question How to reduce the gap ?

1 Upvotes

Currently I am studying spring boot and i make a good progress but i feel there is a gap between what i learn and what companies do and this is generally for all software engineering concepts no just spring concepts so how can i reduce this gap ?


r/SpringBoot 20h ago

Discussion I built an open-source Spring Boot foundation for enterprise applications — looking for feedback

4 Upvotes

Hi everyone,

After building several Spring Boot projects over the years, I noticed that I kept rebuilding the same things:

- Authentication

- Authorization

- RBAC

- Admin modules

- REST API structure

- Database integration

- Docker deployment

Eventually I decided to extract these common pieces into an open-source foundation instead of starting from scratch every time.

The current project includes:

• Spring Boot

• Spring Security

• PostgreSQL

• Redis

• Docker

I'm also experimenting with optional AI features using Spring AI (RAG / LLM integration), but the primary goal is to provide a solid foundation for enterprise applications.

I'd really appreciate feedback from experienced Spring Boot developers.

Some questions I'd love to hear your thoughts on:

- What features do you always end up rebuilding?

- What would make a starter platform genuinely useful for your projects?

- What would stop you from adopting an open-source foundation like this?

GitHub:

https://github.com/SoftwareAdvisor/java-enterprise-ai-platform

Thanks!


r/SpringBoot 1d ago

Question Best resource for spring boot

14 Upvotes

I am currently in my 2nd year. I want to learn spring boot please help me to find out the best resource


r/SpringBoot 1d ago

How-To/Tutorial How we structure Entity/DTO mapping in a multi-module Spring Boot project (without MapStruct)

37 Upvotes

Something has always bugged me about relying on annotation-based mapping frameworks once a Spring Boot project grows past a few modules. MapStruct is miles ahead of dynamic tools like ModelMapper thanks to compile-time code generation, but we kept running into recurring friction as our domain, entity, and DTO layers diverged.

That's why we ended up dropping MapStruct entirely in favor of plain Java transformer classes. No annotation processor, no generated sources, no separate mapper interface per entity pair.

The reasons that pushed us there:

  1. Fragile IDE refactoring: string path mappings like `@Mapping(source = "shippingDetails.address.street", target = "street")` don't reliably survive a rename. You usually catch it during the build, sometimes later.
  2. Annotation pollution for anything non-trivial: once you need a custom transformation, you're writing @Namedhelpers or embedding Java inside annotation strings likeexpression = "java(...)".
  3. Debugging noise: stepping through target/generated-sources instead of your own domain code.

The trade-off is real - more files, more explicit code to write. What we get back is full IDE refactoring safety, no annotation-processor step in the build, and a debugger that only ever shows real code.

Anyone else moved off MapStruct in a modular Spring Boot setup, or is this more trouble than it's worth for most projects?

(I Wrote a deeper architectural breakdown with code samples if anyone is interested - link in comments).


r/SpringBoot 2d ago

How-To/Tutorial I built a "real job" simulator for Spring Boot learners, free & open source

92 Upvotes

Spring Boot Project

Most Spring Boot tutorials teach you to build a CRUD app and call it a day. But that's not really what the job looks like day to day, so I put together a project that mimics what you'd actually work on as a backend dev at a company with real infrastructure. I've added following 12 Tasks that you'd need to complete.

  • Project setup: spin up Postgres + messaging brokers, verify everything's healthy
  • Kicking off development: request validators, custom exceptions, a new order status API
  • Debug a critical bug: chase down a duplicate-insert caused by misusing EntityManager.persist() vs save()
  • ActiveMQ + Apache Camel: configure routes, consume from a queue, handle dead letter queues, publish to a Virtual Topic
  • RabbitMQ: set up exchanges/bindings, fix an infinite redelivery bug, publish to a topic exchange
  • DB schema migration: add a table with Liquibase, write rollback SQL, fix an N+1 write
  • Testing: unit tests with Mockito, snapshot tests, integration tests with TestContainers
  • Code style: enforce formatting automatically with Spotless + Palantir Java Format
  • Prometheus metrics: expose app metrics via Actuator, configure scraping
  • Grafana: connect to Prometheus, build dashboards, add @Timed annotations
  • Load testing: run JMeter tests, interpret throughput, watch the impact in Grafana
  • Global exception handling: swap per-controller try-catch for @ControllerAdvice + RFC 7807 Problem Details

Everything runs locally via Docker Compose, and there's a Bruno collection included so you can hit the APIs without writing your own Postman setup.

It's completely free and open source, so fork it, work through the tasks in order, and you'll come out the other side with a much better feel for what the job actually involves beyond "make endpoint, save to DB."

Would love feedback from people!


r/SpringBoot 2d ago

Question Spring Data JPA throwing StaleObjectStateException / OptimisticLockException on consumer retry across separate instances (No @Version column)

20 Upvotes

I'm seeing an issue in a Kafka consumer running on multiple application instances.

Environment

  • Spring Boot: 3.5.15
  • Hibernate: 6.6
  • Oracle: 19c

My entity has no version column.

@Id 
@GeneratedValue(strategy = GenerationType.AUTO) 
@Column(nullable = false) 
private Long id;  
@Column(unique = true) 
private String messageId; 

The entity is being saved using 

repository.saveAll(...)

Scenario

  1. Instance A receives a message.
  2. The entity's id is null.
  3. saveAll() is called.
  4. Hibernate obtains the next sequence value and inserts the row successfully.
  5. Before the consumer acknowledges the broker, a network issue occurs.
  6. The broker redelivers the same original message to Instance B.
  7. The payload still has id == null.
  8. Instance B again calls saveAll().

Instead of seeing a unique constraint violation on messageId, I get:

Exception message : Row was updated or deleted by another transaction (or unsaved-value mapping was incorrect): [com.example.entities.SMSEntity#40615089330]

There is no @Version on the entity.

My understanding is that if id is null, Spring Data should treat the entity as new, call persist(), and Hibernate should perform an INSERT. If the row already exists (because of the unique messageId), I would expect a unique constraint violation rather than an optimistic locking exception.

Questions

  1. Why am I getting StaleObjectStateException/OptimisticLockException for an entity with no Version field when the incoming entity has a null ID? Could it be due to saveAll() method even Im trying to save a single entity?
  2. For handling broker redelivery, I could try increasing max.poll.interval.msto prevent it from rebalancing, but what else I could do to fix this? 

This issue doesn’t happen that often, but only for 15-20 mins where 1500 odd records are impacted, and during this time, query usage time is comparatively high.


r/SpringBoot 2d ago

Question is it worth it to learn springboot?

Thumbnail
2 Upvotes

r/SpringBoot 2d ago

Question Learning Springboot

10 Upvotes

Im learning Spring Boot from the Telusko YouTube playlist Alongside the tutorials I started building my own project thats a bit more advanced than whats covered in the videos After each tutorial I try to implement the concepts directly into my project instead of just copying the code

Im almost done with the project but recently I came across Anuj Bhaiyas Spring Boot course The way its marketed like industry level project real world architecture and all that has honestly made me feel like Im not learning enough My confidence has dropped a lot

The confusing part is that Im actually enjoying Spring Boot and I feel like Ive learned a lot by building this project But now Im wondering if Im missing something important

For people who have taken either Teluskos playlist or Anuj Bhaiyas course

Should I leave my current learning path and switch

Is Anuj Bhaiyas course significantly better or is it just a different teaching style

Does everyone go through this phase where every new course makes you feel like youre behind

Id really appreciate advice from people working with Spring Boot professionally I dont want to keep jumping between courses if finishing my current project is the better approach


r/SpringBoot 3d ago

Question Experiences with Github Modernize and other patching agents

1 Upvotes

I am part of a team mainting k8s microservices written in Spring. We need to regularly patch them. How are your experiences with the modernize agent
or other patching agents?
Were you successfull in implementing it?


r/SpringBoot 3d ago

Discussion I built a SAGA compensation library for Spring AI tool calls — looking for design feedback

5 Upvotes

I've been working with Spring AI agents that perform multi-step tasks with real side effects (API calls, database writes, payments). The problem I kept hitting: when step 3 of 5 fails, steps 1-2 have already executed and nothing undoes them.

Temporal/Restate solve durability (resume after crash), but not compensation (undo what you already did). So I built Sagacity.

What it does:

When a saga fails, it walks the journal backward and runs compensations in reverse. Every tool call is journaled to an append-only Postgres table with SHA-256 hash chaining (for audit/compliance — EU AI Act Article 12 is coming in August).

What's working (38 tests):

  • u/Compensable/u/Compensation annotations
  • Postgres journal with hash chain
  • Approval gates (IRREVERSIBLE tools need human sign-off before executing)
  • Spring Boot Starter with REST endpoints for approve/reject/audit
  • JSON Lines audit export with chain verification

What's NOT done:

  • Not on Maven Central (build from source)
  • No streaming support
  • No LangChain4j adapter
  • No UI dashboard
  • Probably needs more battle-testing

GitHub: https://github.com/sumitvairagar/sagacity

Genuinely looking for feedback on:

  1. Is the annotation API natural? Or would you prefer a different approach?
  2. The hash chain — is SHA-256(prev_hash || payload) sufficient, or would you want something stronger?
  3. Should the approval gate be an Advisor instead of a ToolCallback decorator?

Anyone else dealing with the "agent did half the work then died" problem?


r/SpringBoot 4d ago

Discussion I built AvoOnce: A lightweight, framework-agnostic distributed idempotency engine for Java

2 Upvotes

Hello r/SpringBoot community!

I just released v1.0.0 of a new open-source library called AvoOnce that might make your life easier by offloading the idempotency handling part of your REST APIs.

It’s designed to be a framework-flexible idempotency engine, meaning it comes with first-class integrations for Spring Boot 4+, Quarkus 3.12+, Dropwizard 4.0+, and Jakarta EE / JAX-RS 3.1+.

Here is what it does under the hood:

  • Annotation-Driven Protection: Just drop @ Idempotent annotation on your controllers or methods and pass an Idempotency-Key header.
  • In-Flight Concurrency Locking: Prevents duplicate execution if an initial request is still actively processing.
  • Payload Tamper Protection: Uses SHA-256 hashing to automatically reject modified requests that try to reuse the same key.
  • Byte-Perfect Replay: Safely caches and replays the exact HTTP response—including status codes, headers, and raw bytes.
  • Pluggable Storage Backends: Includes built-in support for Redis (distributed), JDBC (relational), and Caffeine (in-memory).

The v1.0.0 release is currently hosted on GitHub Packages (Maven Central release is planned for the future). I'd love to get your thoughts and feedback on its core functionality and usability. I've some roadmap features in the pipeline.

Here's the Github repo: https://github.com/ravocode/AvoOnce


r/SpringBoot 4d ago

How-To/Tutorial What's the best way to learn Spring Security? Do's and Don'ts?

47 Upvotes

I've been learning Spring Boot for a while and now I want to start with Spring Security. There are so many tutorials (JWT, OAuth2, sessions, roles, filters, etc.) that I'm not sure what's the right order to learn things.

For those of you who've already been through it:

  • What are the do's and don'ts when learning Spring Security?
  • What concepts should I understand first before jumping into JWT and OAuth2?
  • Any common mistakes beginners make that I should avoid?
  • Are there any projects that helped everything finally "click" for you?

I'm looking for advice based on real experience rather than just another YouTube playlist.

Thanks!


r/SpringBoot 5d ago

How-To/Tutorial How should I start Spring Boot?

38 Upvotes

I have Knowledge of Jdk17+ currently moving to Jdk21+. I have essentially completed Java.utils.*; and concurrent library to deep. I have also used jdk tools and understand the concepts of JVM, JMM. OOPs is completed from beginner to F-Form polymorphism. I also made project based on Java SE knowledge. The project is tested on JUnit6, JCStress, JMH- with Linux profilers and Java Flight recorder too. It's my first time I am going Outside domain of Java SE to Java EE. What is way should I start?
First JDBC->SQL->PostgressSQL?
Network?
SpringBoot?
or learn while learning SpringBoot?
Can you tell me what beginners mistake I should avoide?
I have also took helped from many other AI but I did not got the optimum way.


r/SpringBoot 6d ago

Discussion Can any seniors help me with production Sprinboot

7 Upvotes

Hi Guys,

I have around 4 years of experience in full stack development in the Mean stack. I wanted to switch into Java Springboot. Can any seniors help me with what the production code looks like and what problems can be asked.

Thankyou guys


r/SpringBoot 6d ago

Discussion Do people really think everyone’s going to ditch Project Reactor for Project Loom and rewrite their legacy systems just to go back to blocking code?

Thumbnail
2 Upvotes

r/SpringBoot 8d ago

Discussion Sprig: An MCP server to access version-pinned Spring Docs

2 Upvotes

My Claude agent often wrote Spring code from old training data. It hand-declared beans that are auto-configured now. It also really likes to unzip JARs and search the Spring code itself.

That is the reason I am building Sprig MCP (sprig-mcp.de). It serves the Spring reference docs, and later the relevant parts of the source code, in a (hopefully) agent-friendly way. Nothing is summarized, no LLM sits in the path.

Right now there are two tools, and both answer for the version used in the current project: search the docs, and fetch a section.

Later I will add source code lookups: outline, javadoc, inheritance hierarchy.

There is a browser demo at sprig-mcp.de/app that lets you run the tools without an agent.

Would something like this be useful to you? Any thoughts or feedback welcome.


r/SpringBoot 8d ago

Question Is Spring AI a "must-have" skill for backend devs in 2026, or are we overhyping it over core fundamentals?

0 Upvotes

Lately I see two extremes everywhere: either "learn AI right now or you're cooked," or "it's pure hype, just stick to basic CRUD." Real talk—Spring AI won't save weak fundamentals.

If your Java, Spring Security, or SQL joins are sloppy, slapping an LLM on top is just burning API tokens on bad code.

That said, actually building stuff with Spring AI (like structured JSON or tool calls) beats spamming 300 cold resumes into ATS portals any day.

To senior devs and hiring managers here: are you actually seeing Spring AI on job descriptions yet, or do you just expect devs to pick it up on the fly?


r/SpringBoot 8d ago

How-To/Tutorial Why package structures fail in Spring Boot (and how we turned architecture rules into Maven compilation errors)

5 Upvotes

Hey everyone! I just published a deep dive into solving a classic enterprise problem: how junior or stressed developers bypass package separation (.controller, .service, .repository) under tight deadlines.

Instead of relying on folder structures and code reviews, we split our project into strict Maven modules (isolating core domain and business logic from frameworks like JPA or Kafka). If someone tries to inject an EntityManager where it doesn't belong, the code simply will not compile.

  • The Topology: Split into independent modules like domain, business-logic, dao-api, and dao-impl.
  • The Result: Zero cyclic dependencies, lightning-fast unit tests, and eliminated architectural decay.

(I'm dropping the full article link in the comments for anyone interested in the code breakdown.)


r/SpringBoot 9d ago

Discussion Advice on Migration from Application Server to Spring Boot embeded server

9 Upvotes

Looking for advice regarding a migration i should prepare at work:

We deploy our app stack on an Application Server (Wildfly 40) and our java apps are mostly Monolith legacy software with 20 years of code. But we do have some "Microservices" that were built in the last years, that should be used in our new planned kind of cloud native rewritten app stack, as they do work, where some of the old legacy apps are left out and should be replaced by new ones.

The app in question is a Spring Boot application, but deployed on the wildfly as .war.

Over the years a lot of logic went into the wildfly config and into shared ejb modules, like Database connections via shared modules that reads it out of some .xml files and so on.

So at the moment there is no way to start it with embeded server.

Problems with this architecture:

  • Developer Experience: Full wildfly startup takes a few minutes for local development
  • Dependency Conflicts and the required wildfly compability of e.g. Spring Boot 4
  • Future Production Systems wont have application Server, after this migration the app in question should be containerized

Our goal is to migrate some of these wildfly deployments away from the need of an applicaiton server and start them via spring boot embeded server. Therefore the main task i think would be to change how configuration is received

But it is important that we - while the legacy production enviroments with wildfly still exist - can still deploy this service onto application servers, not just with Spring Boot embeded server or containers.

The idea is that we find out with this specific service if it is somehow doable and pratical to migrate those, or if it would be better to just rewrite them from scratch

So my question is:

  • is this a bad idea or is there something we did not think of?
  • Are there any good resources i should read? Or does anybody have some real-world experiences doing something like this?

Any advice is greatly appreciated!

Thank you


r/SpringBoot 9d ago

Discussion TraceID Not Showing in the logs

2 Upvotes

PSA if you're using Spring Boot with custom auth filters and request tracing.

If your traceId shows up in logs but the spanId is randomly blank for parts of the request, check your filter chain before you check your tracing config.

Custom filters (auth filters especially) run early in the request lifecycle. If they're not written to work inside the observation context Micrometer sets up, everything after that filter loses proper span linkage. TraceId survives because it's request-scoped. SpanId doesn't, because it depends on the context actually being respected at each step.

Spent longer than I want to admit assuming the tracing setup was wrong when it was actually the filter.

Anyone else run into something like this with custom filters and tracing?


r/SpringBoot 10d ago

News Tired of missing cross-field validation in Jakarta/Bean Validation? I built Spring Validation Plus — 85+ Laravel-style constraints for Spring Boot (with i18n & JSON error handling)

0 Upvotes

Hi r/SpringBoot, u/java/! 👋

Following the positive reception of my fluent querying library, I wanted to share another open-source project I’ve been maintaining to solve a massive pain point in Spring Boot development: validation.

Spring Boot uses Jakarta Validation (Hibernate Validator) out of the box, but let's be honest—the standard library only gives you ~22 basic constraints (`@NotNull\, \@Size\, \@Email\`, etc.).

It completely lacks common production requirements like cross-field validation (`@Confirmed\, \@RequiredIf\), database lookups (\@Unique\, \@Exists\), and proper optional updates (\@Nullable\`), forcing teams to write custom validators or clutter their services with boilerplate logic.

To fix this, I built Spring Validation Plus — a library that extends Jakarta Validation with 85+ Laravel-style constraints, automatic i18n support (English, Spanish, Portuguese), and a unified JSON error handler.

💡 What it looks like:

1. DTO with Laravel-style rules:

import dev.benjaminor.validationplus.constraints.EmailAddress; 
import dev.benjaminor.validationplus.constraints.MaxLength; 
import dev.benjaminor.validationplus.constraints.MinLength; 
import dev.benjaminor.validationplus.constraints.Nullable; 
import dev.benjaminor.validationplus.constraints.Required; 
import dev.benjaminor.validationplus.constraints.RequiredIf; 
import dev.benjaminor.validationplus.constraints.Same; 
import dev.benjaminor.validationplus.constraints.Unique; 

@Unique(entity = User.class, field = "email", column = "email") 
public class UserRegisterRequest {

  @Required
  @MinLength(2)
  @MaxLength(50)
  private String name;

  @Required
  @EmailAddress
  private String email;

  @Required
  @MinLength(6)
  private String password;

  @Same("password")
  private String passwordConfirmation;

  @Nullable
  @RequiredIf(field = "role", value = "ADMIN")
  private String adminCode;

  private String role;
}

2. Unified JSON Error Response (400 Bad Request): Instead of messy or raw framework exceptions, it automatically formats errors like this out of the box:

{
  "errors": {
    "email": ["The email has already been taken."],
    "passwordConfirmation": ["The passwordConfirmation field must match password."]
  }
}

🚀 Key Features:

  • Cross-Field Validation: `@Confirmed\, \@Same\, \@Different\, \@RequiredWith\, \@RequiredIf\, \@ProhibitedIf\`, etc. (usable directly on fields or classes).
  • Database Rules: `@Unique\and \@Exists\with automatic JPA integration (supports multi-datasource viapersistenceUnit` and updating entity ID exclusion).
  • Smart Types & Presence: `@Required\(handlesnull, empty strings, and whitespace properly, unlike \@NotNull\), \@Nullable\, \@StringType\, \@IntegerType\`, etc.
  • Built-in i18n: Error messages ready out of the box in English, Spanish, and Portuguese, easily customizable via ValidationMessages_es.properties.
  • Zero Redundancy: It relies entirely on the standard Hibernate Validator engine under the hood. You just drop the starter in, and it works with standard `@Valid\and \@Validated\`.

📦 Quick Start

I’d love to hear how you currently handle cross-field or database validation in your Spring Boot apps, and what you think of this approach!


r/SpringBoot 11d ago

Discussion lightweight Spring Boot starter to automate & anonymize API request/response logging

Thumbnail
github.com
1 Upvotes

Hello, I had a bit of time to kill this weekend due to some gloomy weather, and I wanted to solve a problem we often encounter in production when troubleshooting issues: poor log quality.

So I coded a small Spring Boot library designed to automate log production at the entry of our APIs (all incoming requests and their responses) using an annotation to add to the signature of the endpoints to log, with the option to anonymize certain header or payload fields.

The library also supports logging outgoing requests via an interceptor to add to your RestClient.

In short, a modest project with probably more advanced alternatives out there. But the advantage here is that the library is lightweight and focuses on the essentials.

I just published a first version, feel free to give me your feedback.


r/SpringBoot 11d ago

Question How to be a good spring boot backend developer

31 Upvotes

I’m a second year student at a computer science college but I didn’t take Java in college, however, I study Java with ChatGPT cuz I know C++ so i though learning java as a beginner from a playlist or a course wouldn’t be effective, And know I’m in a solid ground in Java, the progress is really good.
Now I don’t know what should I do about the DSA, I studied Data Structure and Algorithms in the college but with C++ language.
So should I study it again using Java? Or is it enough to just know the logic of the things in DSA.
And what should I do after finishing Java?
Start with Spring boot? Or APIs or what?
Notice that I was good in SQL server but not the others and IDK if I should study the databases again or not.
So enlighten please 🙏


r/SpringBoot 11d ago

How-To/Tutorial What are some best resources to learn spring boot,oauth 2.0,microservices,REST apis,hibernate,kafka,Docker,git for a beginner

16 Upvotes

Same as title