What Is Spring Boot, and Why Did It Replace Plain Java EE?
Java & Spring Boot for Beginners · Part 7 of 14
- #Java
- #Spring Boot
- #Beginners
- #Architecture
Part 6 got you
comfortable reading a pom.xml or build.gradle you didn't write —
dependencies, the compile-test-package lifecycle, the wrapper. That was
deliberately dry, mechanical groundwork. This one is the payoff: what Spring
Boot actually is, mechanically, once you strip away the conference-talk
language about "convention over configuration" and "opinionated defaults."
Part 1 touched this in a couple of paragraphs under "Where Spring Boot fits."
Here's the longer version — the one with the ugly parts in it.
What you had to do before Spring Boot existed
Before you can appreciate what Spring Boot removed, you have to see what it
removed it from. Say you're building a plain Java web application in, say,
2010. Not a toy — something you'd actually deploy. Here's roughly what
stood between you and your first GET /health endpoint:
You'd pick a servlet container — Tomcat, Jetty, JBoss, WebLogic — and
install it on the machine that would run your app, separately from your
code. You'd write a web.xml deployment descriptor to tell that container
which servlets handle which URLs. You'd wire your objects together, either
by hand (new UserService(new UserRepository(new DataSource(...))),
nested three or four levels deep) or with a Spring XML context file that did
the same thing declaratively but was no less tedious to write. You'd
configure JSON serialization, a logging framework, a database connection
pool, and a transaction manager — each with its own setup, and each with
version compatibility you had to verify against every other library in the
mix by hand. Then you'd package all of that into a WAR file (Web
Application Archive) and copy it onto the running container, which was
usually a manual step or a shell script somebody wrote five years earlier
that nobody wanted to touch.
None of this was hard, exactly. It was just a lot of setup that had
nothing to do with your actual feature, that you had to redo — with small
variations — on every new project, and that a typo in web.xml could break
in ways that only showed up once you deployed to a real container.
I still remember how much of "starting a new Java project" used to just be
this — copying an old project's web.xml and Spring context files and
carefully deleting the parts that didn't apply, hoping you didn't delete
something load-bearing. That's the ceremony Spring Boot exists to remove.
Auto-configuration: the part that actually feels like magic
The core trick — and it's worth understanding as a mechanism, not a feeling — is auto-configuration. When your Spring Boot app starts up, it looks at what's on your classpath (which libraries you actually added as dependencies) and registers the beans those libraries need automatically, only if you haven't already configured something yourself. That last clause is the whole design: auto-configuration always backs off the moment you take over.
Concretely: you add spring-boot-starter-data-jpa as a dependency, and a
class annotated @ConditionalOnClass(DataSource.class) somewhere inside
Spring Boot notices that a DataSource class is now on the classpath and
registers a connection pool, an entity manager, and a transaction manager
for you, with defaults tuned for "this will just work for local development
and most production cases." You never wrote a line of that configuration.
If you do want a specific connection pool size, you set one property in
application.properties and auto-configuration steps aside for that one
value while leaving everything else on defaults. It's not magic — it's a
few hundred @Conditional-annotated classes shipped inside the starter
jars, doing pattern matching against your dependency list at startup. You
can read every one of them; they're just Java.
The starters are the other half of this. spring-boot-starter-web
isn't a library with code in it — it's a pom.xml entry with no code of
its own, whose only job is to pull in a curated, tested-together set of
real dependencies (embedded Tomcat, Jackson for JSON, Spring MVC, validation)
at versions Spring Boot's team has already verified play nicely together.
This is the "curated dependency versions" piece from Part 6 on the bill of
materials — starters are where you actually consume that curation. Instead
of you resolving a dozen version conflicts, the Spring Boot team already
did it, once, for everyone.
And the embedded server closes the loop: Tomcat (or Jetty, or Undertow —
your choice) ships as a regular dependency inside your jar, not as
something installed separately on the machine. java -jar app.jar starts
your application and the web server that serves it in the same process.
There's no WAR file, no separate container to install, patch, and keep in
sync with your app's Java version. Deployment became "copy one jar,
run it" — which, not coincidentally, is also exactly the shape containers
and Kubernetes want.
Dependency injection, in one paragraph
None of the above works without dependency injection, so it's worth pinning
down in isolation, without a Spring class name in sight. A class that needs
something — a UserService that needs a way to look up users, say —
declares what it needs as a constructor parameter instead of creating it
itself with new. Something else, a container, is responsible for
building every object in your application in the right order and handing
each one the collaborators it asked for. UserService doesn't know or care
whether it got a real database-backed UserRepository or a fake one built
for a test — it just declares the shape it needs (usually an interface) and
trusts something else to fill it in. That's the entire idea. Spring's
container is one implementation of it; so is Guice; so, honestly, is a
factory function you write by hand in a small program. Spring Boot didn't
invent dependency injection — Spring had it a decade earlier, and the
pattern predates Spring entirely. What Spring Boot did was make the
container itself require zero configuration to stand up.
// Constructor injection: UserService declares what it needs,
// it doesn't build it.
@Service
class UserService {
private final UserRepository repository;
UserService(UserRepository repository) {
this.repository = repository;
}
}
// Versus wiring it by hand, which is what you'd do without a container —
// fine for one class, unmanageable once you have fifty of them
// that depend on each other in a real application.
UserRepository repository = new JpaUserRepository(dataSource);
UserService service = new UserService(repository);
At fifty classes, manual wiring turns into a graph problem nobody wants to
hold in their head — get the construction order wrong and something is
null at runtime, usually the one dependency you were sure was already
set up. A container solves that graph once, generically, for however many
classes you throw at it. @Service, @Repository, @Component are just
labels telling the container "here's something you should manage"; the
container scans for them at startup, works out the dependency graph, and
builds everything bottom-up.
Why Java EE lost this fight
To be fair to Java EE (later renamed Jakarta EE): it wasn't standing still. Later versions added their own dependency injection standard (CDI) and plenty of the concepts here trace back to J2EE patterns from the early 2000s, some of them clumsy in hindsight but genuinely trying to solve the same problems. The difference wasn't really the ideas — it was who owned the defaults and who owned the pace of change. A Java EE application was specified by a committee across multiple vendors, which is a genuinely hard way to ship a new default fast; Spring Boot is one team's opinion, updated on a schedule they control, and you're free to disagree with any single choice and override it. Betting on one team's curated, versioned, actually maintained opinion beat betting on a standards process, and the market answer showed up in job postings and GitHub stars, not in a committee vote.
That's also the honest caveat here: Spring Boot's defaults are opinions, not laws of physics. They're good opinions, tested against enormous real-world usage, but you will eventually meet a case where the default is wrong for what you're building, and Spring makes overriding it a documented, first-class path rather than a fight. That combination — sane defaults, a short and well-worn path to changing any one of them — is the whole value proposition. It's not that Spring Boot writes your application for you. It never touches your business logic. It just stops making you re-solve the same plumbing problem every project reinvented for a decade.
Part 8 stops talking about Spring Boot in the abstract and actually builds
one — a real, running application, from start.spring.io to a working
endpoint, in about ten minutes. Every concept from this post — starters,
auto-configuration, constructor injection — will show up as a concrete file
you can open and read.