Home  >  Article  >  Java  >  What is spring boot?

What is spring boot?

青灯夜游
青灯夜游Original
2022-11-29 11:46:4438707browse

Spring Boot is a Spring-based framework provided by the Pivotal team, which uses a specific way to configure, so that developers no longer need to define boilerplate configurations. Spring Boot integrates most of the currently popular development frameworks. Just like Maven integrates all JAR packages, Spring Boot integrates almost all frameworks, allowing developers to quickly build Spring projects.

What is spring boot?

The operating environment of this tutorial: windows7 system, java8 version, DELL G3 computer.

Spring Boot is a new Spring-based framework provided by the Pivotal team, aiming to simplify the initial construction and development process of Spring applications. The framework uses an ad hoc approach to configuration, eliminating the need for developers to define boilerplate configurations.

The definition given by Spring’s official website is: Spring Boot is the starting point for all Spring-based development projects. Spring Boot integrates most of the currently popular development frameworks. Just like Maven integrates all JAR packages, Spring Boot integrates almost all frameworks, allowing developers to quickly build Spring projects.

The core design idea of ​​Spring Boot is "convention over configuration". Based on this design principle, Spring Boot greatly simplifies project and framework configuration. For example, when using Spring to develop a web project, we need to configure web.xml, Spring and MyBatis, etc., and also need to integrate them together. Everything will become extremely simple using Spring Boot. It uses a large number of default configurations to simplify the configuration process of these files. You only need to introduce the corresponding Starters.

Spring Boot can build everything. It is designed to use the least configuration to start and run Spring projects as quickly as possible.

Background of Spring Boot

Over the years, with the rapid development of Spring and the continuous addition of new features, Spring has become more and more complex.

You can see all of Spring's sub-projects and component frameworks by visiting the Spring official website. So many sub-projects and components make Spring gradually cumbersome, which is obviously unable to adapt to the development trends of the cloud computing and microservices era. .

So Spring Boot came into being. Spring Boot is built on the basis of Spring and follows the principle of "convention over configuration", avoiding the complicated configuration that must be done when creating a project or framework, helping developers use existing Spring more simply and conveniently with the least amount of work. All functional components in .

Features of Spring Boot

A series of features of Spring Boot make it very easy to implement the microservice architecture. For many current technology stacks, Spring Boot is Java The optimal implementation technology of domain microservice architecture.

The following figure shows some features of Spring Boot:

What is spring boot?
Figure 1 Features of Sprint Boot

Core components of Spring Boot

Spring Boot officially provides encapsulation of many currently popular basic functional components. The names generally start with spring-boot-starter, such as the spring-boot-starter-quartz scheduled task component and the spring-boot-starter-thymeleaf page. Template engines, etc.

In addition, due to the popularity of Spring Boot, many third-party middleware also provides Starters for Spring Boot projects in accordance with Spring Boot specifications, generally starting with the component name, such as MyBatis for Spring Boot. The component package mybatis-spring-boot-starter.

The core components of Spring Boot are shown in the figure below:

What is spring boot?
Figure 2 The core components of Spring Boot

Advantages of Spring Boot

Spring Boot inherits the consistent advantages and features of Spring, while adding some new functions and features, which makes Spring Boot very easy to use and also makes Programming becomes easier.

In summary, Spring Boot has the following advantages:
  • Following the principle of "convention over configuration", using Spring Boot only requires very little configuration or uses the default configuration.
  • Use JavaConfig to avoid the hassle of using XML.
  • Provide Starters to simplify Maven configuration and avoid dependency conflicts.
  • Provides embedded Servlet containers, and you can choose to embed Tomcat, Jetty and other containers without the need for a separate web server. This means there is no longer any need to start Tomcat or any other middleware.
  • Provides a series of non-functional features common in projects, such as security monitoring, application monitoring, health detection, etc.
  • Natural integration with cloud computing and microservices.

From the perspective of software development, the simpler the development model, the more popular and dynamic it is. It allows developers to focus on the business logic itself and improves software development efficiency. Spring Boot is to simplify the application development threshold as much as possible, making application development, testing, and deployment easier.

Why learn Spring Boot

In recent years, the most popular technical frameworks in the Spring ecosystem are Spring Boot and Spring Cloud. At present, various enterprises are promoting the implementation of microservice technology architecture, splitting a complex application into multiple small independent modules, deploying them separately without interfering with each other, thereby achieving loose coupling, improving development efficiency and reducing operation and maintenance costs. Purpose.

Spring Boot, as the foundation of the microservice framework, is increasingly used in enterprise-level development. It is the foundation of Spring Cloud. To learn Spring Cloud, you must understand the architecture and design philosophy of the Spring Boot framework.

Spring Boot is a sub-project under the Spring ecosystem, used to quickly and agilely develop a new generation of applications based on the Spring framework. At the same time, it combines various currently mature service frameworks and third-party components (such as Redis, MongoDB, JPA, RabbitMQ, Quartz, etc.) and encapsulates them into Starters components according to the design idea of ​​"convention over configuration". In this way, we can use these components in Spring Boot applications with almost zero configuration to achieve out-of-box use, thereby liberating ourselves from complicated configuration and focusing more on the development of business logic.

The advantages of Spring Boot can be summarized in the following aspects:
  • Quick construction: Using Spring Initializr, you can quickly create projects and provide a wealth of solutions to facilitate the rapid integration of various solutions and improve development. efficiency.
  • Simplify dependencies: Provide rich Starters, simplify Maven configuration, and avoid version compatibility issues.
  • One-click deployment: Embedded Servlet containers, such as Tomcat and Jetty, can be directly packaged into executable JAR files and run independently. It supports Jenkins and Docker to easily realize automated operation and maintenance.
  • Application monitoring: Comes with Actuator monitoring component to easily monitor the status of services. Use Spring Boot Admin to easily deploy a fully functional application monitoring system.

In general, Spring Boot makes building, coding, configuring, deploying, and monitoring very easy. Spring Boot can be said to be one of the most influential projects in the Spring community and even the entire Java community in recent years.

Readers who are learning Spring Boot for the first time should not think of it as too complicated. Spring Boot is not a new language or a new technology. It just integrates existing popular frameworks, follows the principle of "convention over configuration", and works out of the box, so that we no longer need to pay attention to those cumbersome things. configuration. With this concept in mind, you can learn Spring Boot with a relaxed mood.

What is "convention over configuration"

We know that the core design idea of ​​Spring Boot is "convention over configuration", and all Starters provided by Spring Boot are implemented following this idea . So, what exactly is "convention over configuration"?

"Convention over configuration", also known as "programming by convention", is a software design paradigm that aims to reduce the number of configuration items required by software developers, so that the software can remain simple without Loss of flexibility.

Essentially, the system, class library or framework should agree on reasonable default values, and developers only need to specify the parts of the application that do not comply with the agreement. For example, if there is a class named Product in the model, the corresponding table in the database will be named product by default. Only when you deviate from this convention do you need to define configuration about this name, for example, name the table product_info.

To put it simply, "Convention is better than configuration" means following the convention. If the agreed configuration of the tool you use meets your requirements, then you can omit this configuration; if it does not, just modify the relevant configuration to achieve the way you expect.

"Convention over configuration" is not a new concept. Many frameworks use the "convention over configuration" design paradigm, including Maven, Spring, Grails, Grok, Apache Wicket, etc.

Spring Boot is Spring's best practice product of "convention over configuration". From configuration files and default configurations of middleware to built-in containers and various Starters in the Spring ecosystem, they all follow the design philosophy of "convention over configuration". It is precisely because of the simplified configuration and numerous Starters that make Spring Boot simple, easy to use, and easy to get started. It is also the thorough implementation of the design idea of ​​"convention over configuration" that makes Spring Boot achieve glory.

The relationship between Spring, Spring Boot and Spring Cloud

With the continuous development of Spring, Spring Boot and Spring Cloud, more and more developers are joining the Spring army. For beginners, they may not know much about the concepts of Spring, Spring Boot and Spring Cloud and the relationship between them. Let's take a look at them together.

Spring is an open source ecosystem and a master. Its core is Inversion of Control (IoC) and Aspect Oriented Programming (AOP). It is the two core functions of IoC and AOP that make Spring powerful. Spring continues to develop and grow on these two core functions, and has a series of mature products such as Spring MVC, and finally builds a powerful Spring ecological empire. .

Spring Boot is developed on the basis of Spring. It is not intended to replace Spring, but to simplify the creation, running, debugging, and deployment of Spring applications, making it easier for developers to use Spring. It combines various currently mature service frameworks and third-party components, repackages them according to the design idea of ​​"convention over configuration", shields out complex configuration and implementation, and ultimately provides developers with a simple and easy-to-use set of components. , an easy-to-deploy and easy-to-maintain distributed system development toolkit.

Spring Cloud is a distributed microservice framework based on Spring Boot. It uses Spring Boot's simple, easy-to-use, and convenient features to simplify the development of distributed system infrastructure, such as service discovery, service registration, and configuration center. , message bus, load balancing, circuit breaker, data monitoring and other basic components can be started and deployed with one click using the Spring Boot development style.

We all know that when using a microservice architecture, the number of services will be very large, and management will be particularly troublesome. Spring Cloud is a distributed microservice governance framework, which can be said to be the steward of these microservices. As a big housekeeper, Spring Cloud needs to provide various components and solutions to manage and maintain the entire microservice system, such as communication between services, circuit breaker, monitoring, etc. Spring Cloud uses the characteristics of Spring Boot to integrate outstanding components in the open source industry and provides a set of service governance solutions in a microservice architecture.

Spring Boot plays a connecting role in Spring Cloud. If you want to learn Spring Cloud, you must learn Spring Boot. The relationship between the three is shown in the figure below.

What is spring boot?

Figure 3 The relationship between Spring, Spring Boot and Spring Cloud

We can understand it this way: It is precisely because of the two powerful IoC and AOP Only with powerful functions can we have the powerful Spring; the continuous development of the Spring ecosystem has given rise to Spring Boot; the simplification of Spring Boot development and deployment has enabled the Spring Cloud microservice governance solution to be fully implemented.

For more programming-related knowledge, please visit: Programming Teaching! !

The above is the detailed content of What is spring boot?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn