Spring -- the difference between Spring boot and Spring mvc

What is the difference between spring boot and spring mvc? - Zhihu Rutitle https://www.zhihu.com/question/64671972

Author: Qianlong Do Not Use
Link: https://www.zhihu.com/question/64671972/answer/223383505
Source: Zhihu
Copyright belongs to the author. For commercial reprinting, please contact the author for authorization. For non-commercial reprinting, please indicate the source.
 

The Spring framework is like a family, with many derivatives such as boot, security, jpa, etc. But their basis is Spring's ioc and aop. ioc provides a dependency injection container aop, solves cross-section-oriented programming, and then implements other advanced functions of extended products based on these two. Spring MVC is an MVC framework based on Servlet. It mainly solves the problems of WEB development. Because Spring's configuration is very complex, various XML, JavaConfig, and hin are cumbersome to process. Therefore, in order to simplify the use of developers, Spring boot was creatively launched. Convention is better than configuration, which simplifies the spring configuration process.

To put it more simply: Spring originally used the " Factory Pattern " (DI) and the "Agent Pattern" (AOP) to decouple application components. Everyone thought it was very useful, so they built an MVC framework (some components decoupled with Spring) based on this model and used it to develop web applications (SpringMVC). Then I found that I had to write a lot of boilerplate code for every development. In order to simplify the work process, I developed some "lazy integration packages" (starters), which are Spring Boot.

Features of Spring MVC

Spring MVC provides a lightly coupled way to develop web applications.

Spring MVC is a module of Spring, a web framework. Developing web applications becomes easy with Dispatcher Servlet, ModelAndView and View Resolver. The problem areas solved are website application or service development - URL routing, Session, template engine , static Web resources, etc.

Features of Spring Boot

Spring Boot implements automatic configuration and reduces the complexity of project construction.

As we all know, the Spring framework requires a lot of configuration. Spring Boot introduces the concept of automatic configuration to make project setup easy. Spring Boot itself does not provide the core features and extension functions of the Spring framework. It is only used to quickly and agilely develop a new generation of applications based on the Spring framework . In other words, it is not a solution used to replace Spring, but a tool that is closely integrated with the Spring framework to improve the Spring developer experience. At the same time, it integrates a large number of commonly used third-party library configurations (such as Jackson, JDBC, Mongo, Redis, Mail, etc.). These third-party libraries in Spring Boot applications can be used out-of-the-box with almost zero configuration (out-of-the- box), most Spring Boot applications require only a very small amount of configuration code, allowing developers to focus more on business logic.

Spring Boot is just a carrier to help you simplify the project construction process. If you are hosting a WEB project and use Spring MVC as the MVC framework, then the workflow is exactly the same as what you described above, because this part of the work is done by Spring MVC and not Spring Boot.

For users, after switching to Spring Boot, the project initialization method has changed, and the configuration file has changed. In addition, there is no need to install a container server such as Tomcat separately. Maven can create a jar package and run it directly to create a website, but your final There are no changes in the core business logic implementation and business process implementation.

Therefore, to summarize it in the most concise language:

Spring is an “engine”;

Spring MVC is an MVC framework based on Spring;

Spring Boot is a set of rapid development integration packages based on Spring4's conditional registration.

 

Guess you like

Origin blog.csdn.net/Yoke______/article/details/123020974