If you’re studying or working with Java , you’ve probably heard about Spring. Spring is one of the most popular and used Java frameworks . It is a development ecosystem that facilitates the creation of Java applications using several independent modules.
The Spring project grew so much among developers that it was modularized: now each module has its own specialty.
Among the main modules we can mention:
Spring Boot : it facilitates the configuration and publication of the developed applications, aiming to reduce the amount of initial configurations that are generally fundamental in Java projects;
Spring Data: Spring module that aims to facilitate the application’s way of accessing data. It has support from JDBC to JPA;
Spring MVC: Allows the creation and development of applications using the MVC pattern;
Spring Security: Spring module responsible for managing the entire authentication and authorization part of an application.
Spring Boot
Spring Boot is a framework that makes it easy to create self-sufficient and robust Spring applications, enabling them to run immediately.
However, this is only possible due to the opinionated approach on the Spring platform and third-party libraries , which allows the developer to spend as little time as possible configuring the project, but rather coding its business rules.
We won’t go into Spring Boot too much here, as we already have an article explaining what Spring Boot is . It’s pretty complete, check it out 🙂
Spring Web MVC
Spring MVC is a framework that helps us develop web applications. With it, we were able to have ease and flexibility to work with web requests.
Spring MVC is an excellent implementation of the MVC pattern. We already have here on the blog a specific post about the MVC pattern, but in short, MVC (acronym for Model-View-Controller) suggests a way for you to think about the division of responsibilities, especially within a web software, dividing the layers into model, view, controller. With it we can separate the code related to the user interface from the business rules.
It already has the main features we need for development: serving HTTP requests , delegating data processing responsibilities to other components and preparing HTTP responses.
Spring MVC works synchronously, that is, it processes requests one by one, in order of arrival. As long as a request is not completed, it does not process the next one.
Spring MVC, like many other Java frameworks, works with Servlets, which work either synchronously (version prior to Servlet 3), or asynchronously (version from Servlet 3 onwards).
Spring WebFlux
Spring Webflux allows us to work with reactive programming in a java web application within Spring. It works reactively, asynchronously. It came from the need for requests to be processed in parallel, that is, without blocking to deal with concurrency with a number of threads and scale with less hardware resources.
Spring Webflux uses Reactor as its main library, which has 2 types of API:
mono: used when you have operations with 1 data, for example, if I’m going to search for a specific customer in the database
flux: more data, for example if I need a list of customers for a certain store.