Member-only story
Spring Boot Was Taking 25 Seconds to Start — Java 21 Fixed Most of It
For a long time, I ignored it.
Our Spring Boot application took 25 seconds to start.
Locally.
On a decent machine.
“It’s fine,” I told myself.
“Production servers are faster.”
“We don’t restart that often.”
All lies.
One day, during a production incident, we had to restart multiple services. That’s when it hit me: slow startup is not just annoying — it’s operational risk.
So I finally decided to fix it.
This is how I reduced our Spring Boot startup time from ~25 seconds to ~4 seconds, without rewriting the app or switching frameworks.
Step 1: Measure First (Not Guess)
Before changing anything, I turned on startup timing logs.
spring.main.log-startup-info=trueThen I started the app with:
java -jar app.jarSpring Boot logs showed me exactly where time was being spent.
What surprised me?
Most time was not spent in business logic








