Course topics

By WebNest Studio

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

Java
// 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
Output
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

Java
// 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";
    }
}
Output
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

Java
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
Output
(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.

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 the examples

Change an input, predict the result, then compare it with the output. Explain why the result changes.

Use your local JDK or project IDE for these examples. Codelab currently runs Python and HTML/CSS/JavaScript; framework examples may need project dependencies.