Spring Boot Tutorial

Spring Boot - Software Setup and Configuration (STS/Eclipse/IntelliJ)

Prerequisite (Spring Core Concepts)

Spring Boot Core

Spring Boot with REST API

Spring Boot with Database and Data JPA

Spring Boot with Kafka

Spring Boot with AOP

Difference between Spring MVC and Spring Boot

Both Spring MVC and Spring Boot are components of the broader Spring ecosystem, but they cater to different aspects of application development. Let's explore the primary differences between them:

1. Primary Purpose:

  • Spring MVC: Spring MVC is a framework that provides tools to build web applications following the Model-View-Controller pattern. It offers features to handle HTTP requests and responses, data binding, form processing, and much more.

  • Spring Boot: Spring Boot is an opinionated framework built on top of the Spring ecosystem that simplifies the process of building production-ready applications. It eliminates a lot of boilerplate code and configuration.

2. Configuration:

  • Spring MVC: In traditional Spring MVC applications, configuration was often done through XML. Though annotation-based configuration is now prevalent, you still have to manually set up and configure components.

  • Spring Boot: It embraces a convention-over-configuration paradigm. Spring Boot uses sensible defaults and provides Java-based configuration, which makes setting up a Spring application faster and more straightforward.

3. Project Setup:

  • Spring MVC: Setting up a new Spring MVC project requires a bit more effort. You have to manually include required dependencies, configure the web.xml, and set up an application context.

  • Spring Boot: With tools like the Spring Initializr, setting up a new Spring Boot project is a breeze. It provides an easy way to bootstrap a new project with the desired dependencies, and there's no need for a web.xml file.

4. Embedded Server:

  • Spring MVC: Spring MVC doesn't come with an embedded server. To run a Spring MVC application, you have to deploy the war file to an external servlet container or application server like Tomcat, Jetty, etc.

  • Spring Boot: It comes with embedded servers like Tomcat, Jetty, and Undertow, enabling you to run the application without needing an external server. This is particularly useful for microservices, where you can run standalone services easily.

5. Dependency Management:

  • Spring MVC: You need to manage and specify versions of dependencies manually, which could lead to version conflicts.

  • Spring Boot: Provides a set of default dependencies with their known-compatible versions through its starter POMs, reducing potential conflicts.

6. Production-Readiness:

  • Spring MVC: To add features like health checks, metrics, or externalized configuration, you'd need to integrate with other libraries or tools manually.

  • Spring Boot: It comes with "Actuators" that provide out-of-the-box support for various production-ready features, such as health checks, metrics, application environment details, and more.

Conclusion:

While Spring MVC focuses on building web applications using the MVC pattern, Spring Boot offers a comprehensive platform to streamline the development, deployment, and monitoring of applications, web-oriented or otherwise. Spring Boot does encompass Spring MVC when building web applications, making it a superset in terms of features for web development. If you're building a web application, you'll often find yourself using Spring Boot with Spring MVC capabilities under the hood.