By WebNest Studio Engineering Team
Spring Boot Tutorial
Spring vs Spring Boot vs Spring MVC
Beginners often use "Spring", "Spring Boot" and "Spring MVC" as if they meant the same thing, and interviewers love to ask about the difference. They are related but distinct: Spring Framework is the foundation (dependency injection, AOP, transactions, data access); Spring MVC is the web module of that framework; and Spring Boot is an opinionated layer on top that configures everything for you and runs it as a standalone application.
This lesson compares the three, explains Spring Boot's architecture and main features, shows the same "hello" endpoint built the old way and the Boot way, and summarises the Spring Boot version history so you know which tutorials apply to which version.
Spring Framework
The Spring Framework is a comprehensive programming model for Java applications. Its core is the IoC container, which creates objects (beans) and injects their dependencies. Around it are modules for AOP, transactions, JDBC and ORM integration, messaging, testing, and web development (Spring MVC and Spring WebFlux). Before Spring Boot, you had to choose compatible library versions yourself, write XML or Java configuration for every piece, and deploy a WAR file to an external server such as Tomcat.
Spring MVC
Spring MVC is Spring's servlet-based web framework. Its central component is the DispatcherServlet (front controller), which receives every HTTP request, finds the matching @Controller method through handler mappings, converts request data, invokes the method, and renders the result — a view such as Thymeleaf, or JSON via message converters for @RestController. Spring MVC is a part of Spring Framework, and Spring Boot configures it when you add spring-boot-starter-webmvc.
Spring Boot
Spring Boot does not replace Spring; it makes Spring easy to use. Its main features:
- Starters — curated dependency sets with compatible versions.
- Auto-configuration — beans configured automatically based on the classpath and properties.
- Embedded servers — Tomcat (default) or Jetty inside your application; run with
java -jar. - Externalised configuration —
application.properties/yml, profiles, environment variables. - Production features — Actuator health checks, metrics, tracing, graceful shutdown.
- Opinionated defaults — sensible choices you can override, with no XML and no code generation.
- Developer tools — Spring Initializr, DevTools, Docker Compose and Testcontainers support.
Spring Boot Architecture
A Spring Boot application is usually organised in layers: the presentation layer (controllers, JSON/HTML), the business layer (services, validation, transactions), the persistence layer (repositories, entities) and the database. A request flows from the client through the embedded server and DispatcherServlet to a controller, which calls a service, which uses a repository; the response flows back the same way. Spring Boot's role is to wire these layers together automatically at startup: SpringApplication.run creates the ApplicationContext, applies auto-configuration, scans your components and starts the server.
Version History
Knowing the generation of a tutorial avoids confusion:
- Spring Boot 1.x (2014–2019) — the original release on Spring 4.
- Spring Boot 2.x (2018–2023) — Spring 5, Java 8+, WebFlux, Micrometer.
- Spring Boot 3.x (2022–2026) — Spring 6, Java 17+,
javax→jakarta, native images, observability. - Spring Boot 4.x (November 2025 →) — Spring 7, Jakarta EE 11, modular starters, Jackson 3, API versioning, HTTP service clients. This course uses 4.1.
Examples
Before Spring Boot: manual Spring MVC configuration and WAR deployment
// 1. Register the DispatcherServlet yourself
public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {
@Override protected Class<?>[] getRootConfigClasses() { return null; }
@Override protected Class<?>[] getServletConfigClasses() { return new Class<?>[] { WebConfig.class }; }
@Override protected String[] getServletMappings() { return new String[] { "/" }; }
}
// 2. Enable MVC and component scanning yourself
@Configuration
@EnableWebMvc
@ComponentScan("com.webnest.legacy")
public class WebConfig implements WebMvcConfigurer {
// configure message converters, view resolvers, etc. by hand
}
// 3. Choose compatible versions of spring-webmvc, jackson-databind, servlet-api...
// 4. Build a WAR and copy it into an external Tomcat's webapps/ folder
mvn package -> target/legacy-app.war
cp target/legacy-app.war $TOMCAT_HOME/webapps/
$TOMCAT_HOME/bin/startup.sh
With Spring Boot: the same endpoint, runnable with java -jar
// pom.xml: spring-boot-starter-parent + spring-boot-starter-webmvc (versions managed)
@SpringBootApplication
public class HelloApplication {
public static void main(String[] args) {
SpringApplication.run(HelloApplication.class, args);
}
}
@RestController
class HelloController {
@GetMapping("/hello")
String hello() {
return "Hello from Spring Boot";
}
}
mvn package
java -jar target/hello-0.0.1-SNAPSHOT.jar
... Tomcat started on port 8080 (http)
curl http://localhost:8080/hello
Hello from Spring Boot
Comparison table
Aspect | Spring Framework | Spring MVC | Spring Boot
---------------------|---------------------------|----------------------------|------------------------------
What it is | Core framework (IoC, AOP, | Web module of Spring | Opinionated layer on Spring
| transactions, data) | (DispatcherServlet) | that configures and runs it
Configuration | Manual (Java/XML) | Manual (@EnableWebMvc) | Auto-configuration + properties
Dependencies | Choose versions yourself | Choose versions yourself | Starters with managed versions
Server | External (Tomcat, etc.) | External (WAR deployment) | Embedded, java -jar
Production features | Add yourself | Add yourself | Actuator, metrics, health built in
Typical use today | Foundation under Boot | Used through Boot | Default way to build Spring apps
(Spring Boot uses Spring Framework and Spring MVC; it does not replace them.)
Common Mistakes
- Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules.
- Adding @EnableWebMvc in a Spring Boot app, which switches off Spring Boot's MVC auto-configuration.
- Following Spring Boot 2 tutorials (javax.* imports, WebSecurityConfigurerAdapter) on Spring Boot 3 or 4.
- Thinking Spring MVC is only for HTML pages — @RestController APIs are Spring MVC too.
- Deploying Boot apps as WARs by habit when an executable jar or container image is simpler.
Exercise
A teammate is about to make this mistake: Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules. Use Spring Framework to review the decision. Write a corrected implementation or design sketch that follows Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them., then name one edge case you would check.
Show hints
- Start with Spring Framework and compare your approach with Before Spring Boot: manual Spring MVC configuration and WAR deployment. Identify the decision or behavior the lesson recommends.
- Walk through your scenario step by step. Confirm that it follows Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them. and that it would catch the failure described by Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules..
Quick quiz
1. Which choice best describes the recommended approach in Spring vs Spring Boot vs Spring MVC?
- A. Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules.
- B. Adding @EnableWebMvc in a Spring Boot app, which switches off Spring Boot's MVC auto-configuration.
- C. Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them.
Show answer
C. This is the recommended approach: Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them. Avoid: Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules.
Interview questions
Why does this principle matter in Spring vs Spring Boot vs Spring MVC: Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them.
Show answer
Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them. Apply this in Spring Framework; the example Before Spring Boot: manual Spring MVC configuration and WAR deployment shows one way to do it. Avoid Saying Spring Boot replaces Spring — it is built on top of Spring and uses all of its modules. and explain how your implementation or design prevents that failure.
Key Points to Remember
- Spring Framework is the foundation; Spring MVC is its servlet web module; Spring Boot configures and runs them.
- DispatcherServlet is the front controller that routes every request in Spring MVC.
- Spring Boot adds starters, auto-configuration, embedded servers, externalised config and Actuator.
- A typical Boot app has controller, service, repository and database layers wired at startup.
- Know the generation: Boot 2 (javax), Boot 3 (jakarta, Java 17), Boot 4 (Spring 7, modular, Jackson 3).
Practice in the playground
Write and run your own code for this topic, or start from the exercise or an example. Runs plain Java 17. Frameworks such as Spring, and databases, are not available here. Your code for each topic is kept in this browser.
Run the examples
Change an input, predict the result, then compare it with the output. Explain why the result changes.
These examples need a JDK project with their libraries on your computer, so they can be copied but not run here. Codelab runs Python, FastAPI backends with SQLite, plain Java 17 and HTML/CSS/JavaScript.
Written by
WebNest Studio Engineering Team
Practical lessons from developers working with Java, Python, React, databases and production systems.
Led by Vansh Duggal, Founder, WebNest Studio · Full-stack & software engineering