What is Spring?
When we hear word Spring, what comes in our mind.
Spring could mean a lot:
- Spring Framework
- Spring Boot
- Spring Cloud
- Spring Batch
And a lot more….
As a beginner who is new to the Spring world, it is confusing as to what Spring is.
Let’s clear the air, of what Spring is according to Spring Reference Documentation
When people say word “Spring” they mean an entire family of projects.
According to me: Spring is a lightweight, loosely coupled, integration framework, that is used to build java-based enterprise applications.
Lightweight: To create an enterprise application we need jars as well as an environment in which the application runs, Spring applications jars are lightweight and to run a spring-based application we just need a web server. Prior to Spring, we used EJB’s to develop enterprise application which was heavyweight. So, in short, Spring applications are lightweight.
Loosely Coupled: Spring allows to develop applications which are lightly coupled ie easy to modify.
Integration: We can create Spring applications which we can integrate with many other application frameworks such as Angular, React, Hibernate. Spring supports the development of REST-based applications.
Enterprise: Using Spring it becomes easy to create java-based applications which can be used at the enterprise level. Spring removes a lot of boilerplate code.
It all started with Spring Modules
- Spring Core
- Spring AOP
- Spring Web
- Spring Data access
- Spring Test
Spring Modules are like base they are root of Spring Tree. Let’s see purpose of Spring Modules, we will not dig into them but would like to give a brief description
Also read : Spring MVC vs Spring Boot
- Spring Core: It is the foundation of entire Spring Framework, I would say it is the seed, which was planted, and then entire Spring Tree Came up. Spring Core has many features, but main purpose of Spring Core is to develop loosely coupled applications which is achieved by using Dependency Injection which is the implementation of Inversion Of Control Design Pattern.
- Spring AOP: Aspect Oriented Programming, is way to handle cross cutting concerns in our application. What is a cross cutting concern, a cross cutting concern is anything that is common across our code, for example in all classes we need to handle exceptions, so is there any way to handle exceptions better. Spring AOP comes to our rescue and it is used to handle such cross-cutting concerns.
- Spring Web: Conventional development of Web Based application in java was using Servlet API. As it is a low-level API writing complex logic means writing a lot of code. Spring Web (Spring MVC) allows us to easily develop web-based application by using MVC design pattern and separating application logic into Model, View and Controller part.
M means Model which is data of our application
V means View of application UI par
C means controller which is responsible for all coordination taking the request from user via UI coordinating with model and then generate an output on UI.
- Spring Data Access: Developing java-based applications that connected with database was a tedious task. It involved using JDBC, which again like servlet is a low-level API. Spring Data access module allows us to easily connect Spring based applications with database such as Spring JDBC and Spring with Hibernate.
- Spring Test: Spring Test module allows to perform unit and integration testing.
Post this came different Spring Projects that catered to variety of purpose such as Spring Security (for developing secure applications), Spring Social (to connect application with social media websites), Spring Data (applications that connect with sql and no sql db.), Spring Integration (REST based application),, Spring Batch (application with bulk commit operations)and many more.
Check below link for all projects Spring Supports and their purpose. Depending upon the requirement we can select Spring Project
Post-development of Spring Modules and Spring Projects, Spring became so huge that we did not know from where to start.
Then came Spring Boot. Spring Boot makes it easy to start a Spring Based application and is need of todays Spring world. Spring today means Spring Boot.
Today we live in a world where we have started to shift towards microservice based architecture. To support this Spring developers came with Spring Cloud which allows us to build applications that follows distributed architecture. So, we should go for Spring Cloud.
Spring Modules -> Spring Projects -> Spring Boot ->Spring Cloud