Spring MVC Vs Spring Boot:-
Spring MVC Vs Spring Boot is a must have discussion.If you are new to Spring in today’s date. Then you might be confused which framework to choose between spring boot or spring MVC. Spring MVC Vs Spring Boot is a common dilemma for newbie developers.Most of the developers think, Spring Boot being the latest technology we should prefer spring boot. So in this article, I will cover the difference between spring MVC and spring boot.
So let’s get started!
Spring MVC Framework is based completely upon Http or it’s completely HTTP based framework.
If you know about some of the basic server-side Technologies then servlets are one of the most popular ways of developing an MVC based web app.Now let’s remove MVC word above.
So what problem actually does spring covers so spring covers the problem of dependency injection and inversion of control.
So it means we can now easily develop loosely coupled applications using spring.
Spring provides a lot of features and lot of modules. Spring AOP, spring JMS, Spring JPA etc so it reduces the Boilerplate code.
In terms of Integration, we can easily integrate spring along with other frameworks in the market.
What are the problems With Spring:-
So now take a deep breath and think about the problems that you faced while developing full-fledged spring application with all functionalities.
How Difficult was it to setup hibernate Datasource, Entity Manager, Session Factory, Transaction Management etc? It takes a lot of time for a developer to set up a full-fledged basic web app using spring MVC with minimum functionality.
How Spring Boot Solves the Above Problem
Spring-based applications have a lot of configuration. For example, when we use Spring MVC we need to do lots of configurations. Spring boot does all of those using
AutoConfiguration and will take care of all the internal dependencies that your application needs what you just need to do is just run your application and you are good to go for any spring application.We have Something known as
Auto Configuration in Spring Boot.SpringBoot gives us a pre-configured set of Starter Projects to be added as a dependency in our project.
Let us Say we want to develop a Web MVC app using Spring, Spring provides.
Spring Boot Starter Web. Lets See the difference between how we do it in Spring and How we do in Spring Boot?
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-webmvc</artifactId> <version>4.2.2.RELEASE</version> </dependency> <dependency> <groupId>com.fasterxml.jackson.core</groupId> <artifactId>jackson-databind</artifactId> <version>2.5.3</version> </dependency> <dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-validator</artifactId> <version>5.0.2.Final</version> </dependency> <dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
Spring Boot Way:-
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency>
Spring boot takes care of all the internal dependencies that we need for an MVC Project.
Here is the List of Some Of Spring Boot Starter Projects:-
In Short, Spring boot is nothing but it’s just a container where you can run all your spring based applications.