1. Spring MVC :
Spring is widely used for creating scalable applications. For web applications Spring provides Spring MVC framework which is a widely used module of spring which is used to create scalable web applications. Spring MVC framework enables the separation of modules namely Model View, Controller, and seamlessly handles the application integration. This enables the developer to create complex applications also using plain java classes. The model object can be passed between view and controller using maps. In this article, we will see how to set up a Spring MVC application in the Eclipse IDE and understand how to make applications.
The Spring MVC framework consists of the following components :
- Model –
A model can be an object or collection of objects which basically contains the data of the application.
- View –
A view is used for displaying the information to the user in a specific format. Spring supports various technologies like freemarker, velocity, and thymeleaf.
- Controller –
It contains the logical part of the application.
@Controller annotation is used to mark that class as a controller.
- Front Controller –
It remains responsible for managing the flow of the web application. Dispatcher Servlet acts as a front controller in Spring MVC.
2. Spring Boot :
Spring Boot is built on top of the conventional spring framework. So, it provides all the features of spring and is yet easier to use than spring. Spring Boot is a microservice-based framework and making a production-ready application in very less time. In Spring Boot everything is auto-configured. We just need to use proper configuration for utilizing a particular functionality. Spring Boot is very useful if we want to develop REST API. Spring Boot provides the facility to convert our project into war or jar files. Also, the instance of Tomcat can be run on the cloud as well.
There are four main layers in Spring Boot :
- Presentation Layer –
As the name suggests, it consists of views (i.e. frontend part).
- Data Access Layer –
CRUD (create, retrieve, update, delete) operations on the database comes under this category.
- Service Layer –
This consists of service classes and uses services provided by data access layers.
- Integration Layer –
It consists of web different web services(any service available over the internet and uses XML messaging system).
Difference between Spring MVC and Spring Boot :
|S.No.||SPRING MVC||SPRING BOOT|
|1.||Spring MVC is a Model View, and Controller based web framework widely used to develop web applications.||Spring Boot is built on top of the conventional spring framework, widely used to develop REST APIs.|
|2.||If we are using Spring MVC, we need to build the configuration manually.||If we are using Spring Boot, there is no need to build the configuration manually.|
|3.||In the Spring MVC, a deployment descriptor is required.||In the Spring Boot, there is no need for a deployment descriptor.|
|4.||Spring MVC specifies each dependency separately.||It wraps the dependencies together in a single unit.|
|5.||Spring MVC framework consists of four components : Model, View, Controller, and Front Controller.||There are four main layers in Spring Boot: Presentation Layer, Data Access Layer, Service Layer, and Integration Layer.|
|6.||It takes more time in development.||It reduces development time and increases productivity.|