The difference between Spring, SpringMVC and SpringBoot

        Table of contents

What is Spring?

What is Spring MVC?

What is Spring Boot?

The relationship between Spring, SpringMVC and SpringBoot


What is Spring?

Spring is an open source application framework that provides an easy way to develop applications with high cohesion and low coupling through dependency injection and aspect-oriented programming. Spring also provides multiple modules, such as Spring AOP, Spring JDBC, Spring MVC, Spring ORM, Spring JMS, Spring Test, etc., which can be integrated with various third-party frameworks.

What is Spring MVC?

SpringMVC is a module of the Spring framework, which is specially used to build web applications. It implements the MVC pattern and divides the application into three levels: model (Model), view (View) and controller (Controller). The model is the data layer of the application and is responsible for encapsulating business logic and data access. The view is the presentation layer of the application and is responsible for rendering the user interface. The controller is the control layer of the application, responsible for handling user requests and invoking models and views.

SpringMVC uses the front controller pattern to manage all requests uniformly through a core component called DispatcherServlet. DispatcherServlet is responsible for distributing the request to the corresponding controller, and resolving the model and view names returned by the controller into specific view objects, and finally rendering the view to the user.

What is Spring Boot?

Spring Boot is a microservice framework based on the Spring framework, which can quickly create and run independent, production-grade applications. It has the following characteristics:

  • Automatic configuration: According to the dependent packages on the class path, the appropriate components and properties are automatically configured without too many configuration files.
  • Startup dependencies: A series of Starter modules are provided to easily introduce commonly used dependency packages and manage their versions and compatibility.
  • Embedded container: Supports embedded Tomcat, Jetty, Undertow and other web containers, and can directly run jar packages without deploying war packages.
  • Health checks and metrics: The Actuator module is provided to monitor and manage application health and performance metrics.
  • External configuration: supports multiple ways to configure application properties, such as properties files, yaml files, environment variables, command line parameters, etc., and supports dynamic refresh.

The relationship between Spring, SpringMVC and SpringBoot

From the above introduction, we can see that there is a close relationship between Spring, SpringMVC and SpringBoot:

  • SpringMVC is a web development module based on the Spring framework. It uses features such as dependency injection, transaction management, and AOP provided by the Spring framework, and can be integrated with other Spring modules.
  • SpringBoot is a microservice framework based on the Spring framework. It uses SpringMVC as a web development component and can introduce other Spring modules as a starting dependency. It also provides features such as auto-configuration, embedded containers, health checks, etc., which simplify the development and deployment of applications.

Therefore, it can be said that SpringBoot > SpringMVC > Spring , that is, SpringBoot contains SpringMVC, and SpringMVC contains Spring . But this does not mean that using SpringBoot does not need to understand or use Spring or SpringMVC. On the contrary, when using SpringBoot, you also need to understand the basic principles and configuration methods of Spring and SpringMVC, so that you can customize and tune when needed.

Guess you like

Origin blog.csdn.net/TaloyerG/article/details/132466167