Spring Framework vs Spring Boot: What Boot Actually Adds
System DesignModel answerLast updated
Explain how Spring Boot relates to the core Spring Framework, covering configuration, auto-configuration, servers, dependencies, startup and when to pick each.
A teammate new to the Java ecosystem asks: "If we already use Spring, why do people keep saying we should use Spring Boot? Aren't they the same thing?"
Give a structured comparison of the Spring Framework and Spring Boot. Your answer should cover:
- Relationship: how the two relate to each other.
- Configuration style: what you write by hand in each, with a short example.
- Auto-configuration: the mechanism behind it and how you control or override it.
- Server model: external application server versus embedded server.
- Opinionated defaults and dependency management.
- Startup flow: what happens from process start to a running application in each model.
- Use cases: when you would still choose plain Spring, and when Boot is the better fit.
Be concrete: name annotations, files and build artifacts, and call out common misconceptions.
Hints
Hint 1
Start with the relationship: one of the two is built on top of the other, so decide whether this is a 'versus' at all.
Hint 2
For auto-configuration, think about three things: where the candidate classes are registered, which conditions guard them, and what happens when you define your own bean.
Hint 3
For startup, compare who is in charge of whom: in one model a server launches your app, in the other your `main` method launches the server.
Model answer
Medium Try it yourself first — then compare your approach, complexity and edge cases.
Short answer
Spring Boot is not a competitor to the Spring Framework. It is an opinionated layer on top of it. The Framework supplies the building blocks (dependency injection container, AOP, MVC/WebFlux, transactions, JDBC/ORM support). Boot decides how to assemble those blocks, using sensible defaults you can override.
Spring gives you the tools and leaves the wiring to you. Boot wires them for you and steps aside when you say otherwise.
Side-by-side
| Aspect | Spring Framework | Spring Boot |
|---|---|---|
| Configuration | Explicit XML or Java @Configuration; you declare infrastructure beans | @SpringBootApplication plus application.properties or application.yml |
| Auto-configuration | None; you define DataSource, DispatcherServlet, view resolvers, etc. | Conditional beans created from classpath contents and properties |
| Server | Package a WAR and deploy it to an external Tomcat, JBoss or WebLogic | Embedded Tomcat (default), Jetty or Undertow; Netty for WebFlux; run with java -jar |
| Defaults | Unopinionated | Opinionated: Jackson, HikariCP, Logback, Tomcat |
| Dependencies | You pick each artifact and version | Starters plus a curated BOM |
| Startup | Container-driven (web.xml or WebApplicationInitializer) | main() calls SpringApplication.run() |
| Operations | Add yourself | Actuator (health, metrics, info), profiles, relaxed binding |
Configuration
Plain Spring MVC needs you to declare infrastructure and a servlet initializer:
@Configuration
@EnableWebMvc
@EnableTransactionManagement
@ComponentScan("com.example")
public class AppConfig {
@Bean
public DataSource dataSource() {
HikariDataSource ds = new HikariDataSource();
ds.setJdbcUrl("jdbc:postgresql://localhost/app");
ds.setUsername("app");
ds.setPassword("secret");
return ds;
}
@Bean
public PlatformTransactionManager txManager(DataSource ds) {
return new DataSourceTransactionManager(ds);
}
}
public class WebInit extends AbstractAnnotationConfigDispatcherServletInitializer {
protected Class<?>[] getRootConfigClasses() { return new Class<?>[]{AppConfig.class}; }
protected Class<?>[] getServletConfigClasses() { return null; }
protected String[] getServletMappings() { return new String[]{"/"}; }
}
The Boot equivalent:
@SpringBootApplication
public class App {
public static void main(String[] args) {
SpringApplication.run(App.class, args);
}
}
spring:
datasource:
url: jdbc:postgresql://localhost/app
username: app
password: secret
@SpringBootApplication is a meta-annotation combining @SpringBootConfiguration, @EnableAutoConfiguration and @ComponentScan.
How auto-configuration works
It is not magic; it is conditional bean registration.
- Registration. Candidate classes are listed in
META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports(Boot 2.7+; earlier versions usedspring.factories). - Conditions. Each class is guarded by conditions such as
@ConditionalOnClass(is HikariCP present?),@ConditionalOnMissingBean(did the user already define aDataSource?),@ConditionalOnPropertyand@ConditionalOnWebApplication. - Back-off. User-defined beans win. Boot fills gaps only, so declaring your own bean overrides the default.
- Control.
- Exclude:
@SpringBootApplication(exclude = DataSourceAutoConfiguration.class)orspring.autoconfigure.exclude. - Tune: properties bound via
@ConfigurationProperties. - Inspect: run with
--debugfor the conditions evaluation report, or use/actuator/conditions.
- Exclude:
Embedded servers
- Classic Spring: the app is a WAR run inside a server you install and patch separately. Server version and settings live outside the codebase.
- Boot: the server is a library inside the app.
spring-boot-starter-webpulls in Tomcat; excluding it lets you swap in Jetty or Undertow. The Boot Maven/Gradle plugin builds an executable fat JAR, which suits containers and microservices (one process, one port). - WAR is still possible. Extend
SpringBootServletInitializerand package as WAR when an organization mandates WebLogic or WebSphere.
Dependency management
- Spring: you choose
spring-webmvc,jackson-databind,hibernate-core, a connection pool and so on, each with a compatible version. Mismatches show up as runtime errors likeNoSuchMethodError. - Boot: starters (
-web,-data-jpa,-security,-test) bundle the usual dependencies, and the BOM (spring-boot-starter-parentor importedspring-boot-dependencies) pins tested versions, so you normally omit version numbers.
Startup flow
Classic Spring (WAR):
- The servlet container starts.
- It reads
web.xmlor discovers aWebApplicationInitializer. ContextLoaderListenerbuilds the rootApplicationContext.DispatcherServletcreates a child web context.- Context refresh instantiates the beans.
Spring Boot:
main()callsSpringApplication.run().- Boot infers the app type (servlet, reactive, none).
- Initializers and listeners are loaded.
- The
Environmentis prepared. Property precedence, high to low: command line, environment variables, profile-specific files, thenapplication.yml. - The banner prints and the context is created (e.g.
ServletWebServerApplicationContext). - Auto-configuration loads and the context refreshes; the embedded server starts during refresh.
CommandLineRunnerandApplicationRunnerbeans run.ApplicationReadyEventis published.
The inversion to remember: in classic Spring the server starts the app; in Boot the app starts the server.
When to choose which
Plain Spring Framework
- Maintaining legacy XML/WAR applications on a managed application server.
- Writing a library or framework that must not impose Boot's defaults or dependencies.
- Needing total explicit control over every bean.
Spring Boot
- New services, REST APIs, microservices, batch jobs.
- Containerized or cloud-native deployments (Docker, Kubernetes).
- Teams that want fast onboarding, consistent conventions, and built-in health checks and metrics.
Trade-offs
- Boot reduces boilerplate but hides wiring; debugging an unexpected bean requires knowing how to read the conditions report.
- Fat JARs are larger and bundle their own server, but remove the "works on my server" class of problems.
- Opinionated defaults speed up delivery yet can surprise you (for example, an auto-configured
DataSourceappearing because a driver is on the classpath).
Common mistakes
- Calling them "alternatives." Every Boot app is a Spring app.
- Claiming Boot removes the need to understand Spring (beans, scopes, proxies and transactions work identically).
- Saying Boot cannot produce WARs, or that auto-configuration cannot be overridden.
- Forgetting that Boot's BOM is what prevents version conflicts, not just starters.
- Describing Actuator as part of core Spring rather than a Boot feature.