English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
Spring Boot is an open-source framework for creating microservices based on Java. It is developed by the Pivotal Team to build independent and production-ready Spring applications. This chapter will introduce you to Spring Boot and familiarize you with its basic concepts.
Spring: Spring framework is the most popular Java application development framework. The main features of Spring framework areDependency injectionorInversion of Control(IoC). With the help of Spring Framework, we can develop aLoose couplingapplication. If purely defining the type or characteristics of the application, it is best to use.
SpringBoot: Spring Boot is a module of Spring Framework. It allows us to build independent applications with the least configuration or zero configuration. If we want to develop a simple Spring-based application or RESTful service, it is best to use it.
The main comparison between Spring and Spring Boot is discussed as follows:
by Spring | Spring Boot |
Spring FrameworkIs a widely used Java EE framework for building applications. | SpringBoot Framework Is widely used for development REST API . |
It is designed to simplify Java EE development, making developers more efficient. | It is designed to shorten the length of code and provide development Web applicationThe simplest method. |
The main feature of Spring Framework isDependency injection. | The main feature of Spring Boot isAutomatic configuration. It will automatically configure classes based on requirements. |
By allowing us to developLoose couplingApplications that can make things simpler. | It helps to create configurations with fewerIndependentApplication. |
Developers have written a lot of code (Template code) to complete the smallest task. | ItReduceSample code. |
To test Spring projects, we need to explicitly set up the server. | SpringBoot providesembedded serversFor example Jetty and Tomcat etc. |
It does not support in-memory databases. | It provides multiple plugins to handle embedded andin memorydatabases, such as H2 . |
Developers in pom.xml manually define dependencies for Spring projects. | Spring Boot includes in the pom.xml file starter concept, which internally handles the download of dependencies according to Spring Boot requirements JAR . |
Spring Boot: Spring Boot makes it easy to quickly boot up and start the development process based on Spring. It avoids a lot of boilerplate code. It hides a lot of complex information, so developers can get started quickly and easily develop applications based on Spring.
Spring MVC: Spring MVC is a web MVC framework used for: building web applications. It contains many configuration files for various functionalities. It is a framework for web application development面向HTTP.
Spring Boot and Spring MVC exist for different purposes. The following discusses the main comparisons between Spring Boot and Spring MVC:
SpringBoot | SpringMVC |
SpringBoot It is a module of Spring used to package applications based on Spring with reasonable default values. | SpringMVC It is a web framework based on Model-View-Controller under the Spring framework. |
It provides tools for building by Spring-powered default configuration of the framework. | It providesEasy to useFunctions to build web applications. |
No manual build configuration is needed. | It requires manual build configuration. |
Not neededDeployment descriptor. | Essential. |
It avoids boilerplate code and wraps dependencies in a unit. | It specifies each dependency separately. |
ItReducedevelopment time and improve productivity. | It takes the same time to takeMore. |
SpringBoot is a module of the Spring framework. It is used to easily create standalone, production-grade applications based on Spring. It is developed on top of the core Spring framework.
SpringBoot follows a layered architecture, where each layer communicates with its immediate lower or upper layer (hierarchy).
before understanding SpringBoot Architecture After that, we must understand the different layers and classes within it. In SpringBoot, there arefourlayers, as shown below:
Presentation Layer Business Layer Persistence Layer Database Layer
Presentation Layer: The presentation layer is responsible for handling HTTP requests, converting JSON parameters to objects, and authenticating requests and transmitting them to the business layer. In short, it consists ofViewwhich consists of the front-end part.
Business Layer: The business layer handles allBusiness Logic >. It consists of service classes and uses services provided by the data access layer. It also executesAuthorizationandValidation.
Persistence Layer: The persistence layer contains allStorage Logicand convert business objects to database rows and vice versa.
Database Layer: In the database layer, CRUD (Create, Retrieve, Update,)
Now we have validator classes, view classes, and utility classes. Spring Boot uses all modules similar to Spring MVC, Spring Data, etc. The architecture of SpringBoot is the same as that of Spring MVC, the difference being: it does not require DAO and DAOImpl Class in Spring startup.Create the data access layer and perform CRUD operations.The client sends an HTTP request (PUT or GET).The request is sent to the controller, which then maps the request and processes it. After that, if necessary, it will call the service logic.All business logic will be executed in the service layer. It performs logic on the data mapped to JPA through class mapping.If no error occurs, the JSP page will be returned to the user.