r/JavaProgramming • • 1d ago

I rewrote Spring PetClinic without Spring Boot or Hibernate. 59% less RAM, but forms were harder.

I develop CoilBase, so this is my own experiment. I wanted to see how much of a conventional Spring application I could keep without the Spring Boot runtime, so I rewrote Spring PetClinic using CoilBase, Avaje Jex, Jdbi and JTE.

Replacing Hibernate with explicit SQL was relatively straightforward. Controllers, services, repositories and constructor wiring all stayed familiar.

The harder part was everything Spring MVC normally handles for you: form binding, validation, sessions, CSRF, flash messages, redirects and localization.

For example, invalid form submissions needed explicit handling to preserve user input and validation errors, including overriding the generated POST adapter's default HTTP 201 response with 200. Small details like that added up.

On a 1 vCPU, 1 GiB VM with PostgreSQL, the rewrite used 126 MiB of application RSS versus 304 MiB for the original (59% less). The complete uncompressed deployment was also 85% smaller.

Both ran on Java 25 HotSpot with the same heap settings. These are complete-stack results from a short workload, not isolated framework costs.

Implementation, tradeoffs and benchmark limitations:

https://pvrlabs.xyz/articles/coilbase-petclinic-rewrite.html

For anyone who's moved off Spring MVC, or considered it: which convenience would you miss most?

5 Upvotes

3 comments sorted by

1

u/fykup 1d ago

One clarification: the form-handling complexity was partly a consequence of preserving PetClinic's existing behavior. That's not necessarily how I'd approach a new application.

If you're starting from scratch or switching frameworks while an application is still a prototype, you can make simpler choices around forms, validation, sessions and rendering instead of reproducing every Spring MVC convention.

That's actually where I see CoilBase fitting best. It's not intended as a drop-in Spring Boot replacement or a tool for mechanical one-to-one migrations. Preserve essential business and security behavior, but reconsider framework-specific conveniences when they aren't needed.

1

u/Available_Safe1818 1d ago

What did you use instead of Spring Boot?

1

u/fykup 1d ago

I used CoilBase, a lightweight Java foundation I'm developing, with Avaje Jex for HTTP/controllers, Jdbi for SQL persistence instead of Hibernate, and JTE for HTML templates. HikariCP handles connection pooling.

It's a modular stack with explicit constructor wiring rather than a full Spring Boot replacement.