Do you really know the difference between Spring and SpringBoot?

1. Introduce SpringBoot

​ Before introducing SpringBoot, let's briefly introduce Spring. Spring is a Java development framework born in 2002, and it can be said that it has become the de facto standard for Java development. The so-called de facto standard is that although Java officials do not say that it is a development standard, among the many projects currently developed in Java, when we talk about product-level Java projects, most of them are based on Spring or apply Spring features.

Based on the two features of IOC and AOP, Spring greatly simplifies Java development itself. But a large-scale project needs to integrate many other components. For example, a WEB project must at least integrate MVC framework, WEB container such as Tomcat, log framework, ORM framework, and choose a connection pool to connect to the database... If you use Spring, you need to integrate each component You have to write its configuration file first, which is cumbersome and error-prone.

Then there is SpringBoot.

Spring Boot is a new framework provided by the Pivotal team. Spring Boot 1.0 was released in April 2014 and Spring Boot 2.0 was released in March 2018. It is a further package of spring, and its design purpose is to simplify the initial construction and development process of Spring applications. How to simplify it? It is to make it easier for us to use by encapsulating, abstracting, and providing default configurations.

SpringBoot is developed based on Spring. SpringBoot itself does not provide the core features and extended functions of the Spring framework, that is to say, it is not a solution to replace Spring, but a tool that is closely integrated with the Spring framework to improve the Spring developer experience.

There is a well-known saying about SpringBoot that convention is greater than configuration. Using Spring Boot can greatly simplify the development model. It integrates a large number of commonly used third-party library configurations. All common frameworks you want to integrate have corresponding component support, such as Redis, MongoDB, Jpa, Kafka, Hakira, etc. These third-party libraries in SpringBoot applications can be used almost out of the box with zero configuration. Most SpringBoot applications only require a very small amount of configuration code, allowing developers to focus more on business logic.

2. Why does SpringBoot appear?

The birth background of Spring Boot is not only to simplify the development based on the Spring framework, but also because of the rise of the microservice architecture. In 2014, Martin Fowler published a blog introducing microservices, which pushed the microservice architecture style to the public view. Compared with monolithic applications, the microservice architecture splits applications into a set of small services, each of which runs in its own process and communicates with each other through HTTP and other methods. This architectural style provides developers with better maintainability and scalability.

​ Spring Boot is a new generation of application development framework based on the Spring framework, and its goal is to help developers develop quickly and agilely. Compared with the traditional development method based on the Spring framework, Spring Boot not only provides rapid development capabilities, but also integrates a large number of commonly used third-party library configurations, such as Redis, MongoDB, JPA, RabbitMQ, Quartz, etc. These libraries can be configured with zero Go out of the box. This greatly reduces the cost of learning and configuration for developers, allowing developers to focus more on business logic.

Although the traditional monolithic application architecture also has advantages, such as relatively simple testing and deployment, and convenient horizontal expansion, its shortcomings are also very obvious. A single application often affects the whole body. Changing a small function requires redeploying the entire application, which is a burden for developers and operation and maintenance personnel. Moreover, as user demands continue to grow, it is difficult for a single application to meet these demands, which requires a more flexible and scalable architecture.

​ In addition, Spring Boot also provides various tools and plug-ins, such as Spring Boot CLI and Spring Boot Actuator, etc. These tools can help developers develop, test and deploy more conveniently.

​ In short, Spring Boot was born to adapt to the changes and needs of the times. It provides developers with a faster, agile, scalable and maintainable development method, and also provides enterprises with a more stable and reliable application architecture.

3. What are the advantages of SpringBoot?

1. Improve development efficiency

Spring Boot provides a wealth of solutions that make development simple and efficient. Developers only need to introduce the corresponding dependent libraries to quickly integrate various solutions, thereby improving development efficiency. In addition, Spring Boot also provides a large number of Starters, which integrate mainstream open source products and are very convenient to use.

2. Simplified configuration

Spring Boot simplifies application configuration through an automatic configuration mechanism. Developers only need to configure some necessary parameters without paying attention to too many details. In addition, Spring Boot's automatic configuration mechanism can also automatically adjust configuration parameters according to the application environment, so that developers do not need manual intervention.

​3. Easy deployment

Spring Boot embeds the startup container, so only one command is needed to start the project. This makes deployment very easy and fast. In addition, combined with tools such as Jenkins and Docker, automated operation and maintenance can be realized, further improving deployment efficiency and reducing error rates.

4. Simplify Monitoring

The monitoring component that comes with Spring Boot can easily monitor the status of services. Using Actuator, you can obtain information such as the health status of the application, performance bottlenecks, and runtime status, which is convenient for developers to tune and optimize the application. In addition, Spring Boot also supports the integration of various monitoring tools, such as Prometheus, Grafana, etc.

In short, Spring Boot can bring a lot of convenience and efficiency improvements to developers in all aspects. Its birth also represents that Java development has entered a new stage and will play an increasingly important role in the field of software development in the future.

4. What are the characteristics of SpringBoot?

​1. Spring project running independently

Spring Boot allows the application to be packaged as a jar file and started in a stand-alone manner. This means we don't need to install an additional server or environment to run our application. We only need to run one command, and we can start the application, which greatly simplifies the complexity of deployment and operation.

2. Embedded Servlet container

Spring Boot embeds commonly used Servlet containers such as Tomcat, Jetty, and Undertow, and the application does not need to be packaged as a WAR package. This makes Spring Boot applications very lightweight and get up and running quickly.

​3. Provide starter to simplify Maven configuration

Spring Boot provides a number of starter POMs, which are predefined collections of dependencies that make it easy to integrate third-party libraries into our application. By using starter POMs, we can avoid manually adding a lot of dependencies, making Maven configuration much simpler.

​4. Provide a lot of automatic configuration

The automatic configuration feature of Spring Boot greatly simplifies application development. Spring Boot can automatically configure most of the components according to the needs of our application, and we only need to configure a small amount of content. This greatly improves development efficiency.

​5. Self-contained application monitoring

Spring Boot also has the ability to monitor applications, which can automatically expose various indicators, health status and measurements. These metrics can be accessed through HTTP endpoints, so we can easily view the status of the application through the browser or monitoring tools.

6. No code generation and XML configuration

Spring Boot allows us to develop without XML configuration. This means we can use annotations and code to configure the application. This development method is more intuitive and easy to maintain, and can also avoid the cumbersome and lengthy XML configuration files.

7. Simplified dependency management

Spring Boot can automatically manage dependencies, reducing the problem of dependency version conflicts in the project, allowing developers to focus more on the implementation of business logic.

8. Provides rich annotations

Spring Boot provides a wealth of annotations, which can help developers configure and develop more conveniently, and also improve the readability of the code.

​9. Integrates various development tools

Spring Boot integrates various development tools, such as Spring Tool Suite (STS), IntelliJ IDEA, Eclipse, etc., making it easier for developers to develop, test, and deploy.

​10. Support multiple data sources and multiple databases

Spring Boot supports a variety of data sources and databases, including MySQL, PostgreSQL, Oracle, MongoDB, etc., allowing developers to choose the most suitable database and data source according to the needs of the project.

In short, Spring Boot is a very powerful and flexible development framework, which can greatly improve the development efficiency of developers and the deployment efficiency of projects.

5. What are the differences between Spring and SpringBoot?

Spring SpringBoot
Spring is an open source lightweight framework widely used for developing enterprise applications Spring Boot builds on the traditional Spring framework and is widely used to develop REST APIs
The most important feature of the Spring framework is dependency injection The most important feature of Spring Boot is automatic configuration
Helps create loosely coupled applications Helps to create a standalone application such as microservices etc.
To run a Spring application we need to explicitly set the server Spring Boot provides embedded servers such as Tomcat and Jetty
To run a Spring application, a deployment descriptor is required No deployment descriptor required
To create a Spring application, developers need to write a lot of code and configuration Significantly reduces code and configuration lines
In-memory database support is not provided by default Support for in-memory databases is provided by default, such as H2

6. Summary

​ Spring Boot is a tool for the Spring framework. It was originally designed to simplify the Spring configuration process, allowing developers to focus more on application development and business logic implementation without paying too much attention to configuration issues. It adopts the concept of "default is greater than configuration" and provides many integrated solutions so that developers can easily perform zero or minimal configuration when developing applications. At the same time, in order to maintain flexibility, it also supports custom operations.

​ Spring Boot has many built-in starters, which can help developers quickly configure and use common functions and components, such as Email services, Web development, databases, and so on. Developers only need to add the corresponding dependencies to use, which can greatly reduce the workload of configuration.

​ In addition to fast integration, Spring Boot also provides a large number of automated configurations that can help developers develop more efficiently. It eliminates the cumbersome XML file configuration required in Spring, making development faster, more efficient, and more automated.

In short, the emergence of Spring Boot makes it easier for developers to develop and deploy applications, saves tedious configuration work, and allows developers to focus more on the implementation of business logic.

Guess you like

Origin blog.csdn.net/MaoXiaoMiaoYa/article/details/129654555