I have just started learning Spring. In my next step, I would like to develop bigger web applications.
Now I am wondering if I should start with Spring Boot or Spring MVC. I have already read some stuff, but it is confusing because both look similar.
So what are the differences between the two?
This question is related to
spring
spring-mvc
spring-boot
Using spring boot you will no need to build configuration. This will have done automatically when you create project.
If you use spring MVC you need to build configuration yourself. It is more complicated, but it is crucial.
Spring MVC
is a sub-project of the Spring Framework, targeting design and development of applications that use the MVC (Model-View-Controller) pattern. Spring MVC is designed to integrate fully and completely with the Spring Framework and transitively, most other sub-projects.
Spring Boot
can be understood quite well from this article by the Spring Engineering team. It is supposedly opinionated, i.e. it heavily advocates a certain style of rapid development, but it is designed well enough to accommodate exceptions to the rule, if you will. In short, it is a convention over configuration methodology that is willing to understand your need to break convention when warranted.
SpringBoot is actually pre configured that reduced boiler configuration and providing easiest or quick way to start your application.
SpringBoot take the headache of configuration from developer to it's own self rather than Spring.
Implicitly SpringBoot is based on Spring framework concept like bean, controller , services, jpa etc.
You can say that SpringBoot is a wrapper of Spring.
In SpringBoot by default port of Server is 8080 but if you want to change then go to your application.properties and write
server.port = 8084
Spring MVC and Spring Boot are exist for the different purpose. So, it is not wise to compare each other as the contenders.
What is Spring Boot?
Spring Boot is a framework for packaging the spring application with sensible defaults. What does this mean?. You are developing a web application using Spring MVC, Spring Data, Hibernate and Tomcat. How do you package and deploy this application to your web server. As of now, we have to manually write the configurations, XML files, etc. for deploying to web server.
Spring Boot does that for you with Zero XML configuration in your project. Believe me, you don't need deployment descriptor, web server, etc. Spring Boot is magical framework that bundles all the dependencies for you. Finally your web application will be a standalone JAR file with embeded servers.
If you are still confused how this works, please read about microservice framework development using spring boot.
What is Spring MVC?
It is a traditional web application framework that helps you to build web applications. It is similar to Struts framework.
A Spring MVC is a Java framework which is used to build web applications. It follows the Model-View-Controller design pattern. It implements all the basic features of a core spring framework like Inversion of Control, Dependency Injection.
A Spring MVC provides an elegant solution to use MVC in spring framework by the help of DispatcherServlet. Here, DispatcherServlet is a class that receives the incoming request and maps it to the right resource such as controllers, models, and views.
I hope this helps you to understand the difference.
Spring MVC and Spring Boot are well described in other answers, and so without repeating that, let me jump straight to the specifics. Spring Boot and Spring MVC are not comparable or mutually exclusive. If you want to do web application development using Spring, you would use Spring MVC anyway. Your question then becomes whether to use Spring Boot or not.
For developing common Spring applications or starting to learn Spring, I think using Spring Boot would be recommended. It considerably eases the job, is production ready and is rapidly being widely adopted.
I have seen sometimes beginners asking this question because in STS (Spring Tool Suite) there are two wizards: one for creating a Spring Boot project, and another for creating a Spring MVC project. So, my recommendation would be to create a Spring Boot project and choose Web as a module in that.
Here is some main point which differentiate Spring, Spring MVC and Spring Boot :
Spring :
Spring MVC
Spring Boot :
(Evolution like : Spring -> Spring MVC -> Spring Boot, So newer version have the compatibility of old version features.) Note : It doesn't contain all point.
Think this way:
Spring MVC is a web based framework to implement the MVC architecture.
Spring Boot is a tool oriented to the programmer. Programmer must focus on programming and tool must focus on configurations. So we don't need to wast our time configuring a bunch of xml to make a simple 'Hello world'.
In simple term it can be stated as:
Spring boot = Spring MVC + Auto Configuration(Don't need to write spring.xml file for configurations) + Server(You can have embedded Tomcat, Netty, Jetty server).
And Spring Boot is an Opinionated framework, so its build taking in consideration for fast development, less time need for configuration and have a very good community support.
To add my once cent, Java Spring is a framework while Java Spring Boot is addon to accelerate it by providing pre-configurations and or easy to use components. It is always recommended to have fundamental concepts of Java Spring before jumping to Java Spring Boot.
Without repeating the same thing in previous answers,
I'm writing this answer for the people who are looking to starting a new project and don't know which is the best framework to startup your project.
If you are a beginner to this framework the best thing I prefer is Use spring boot(with STS /Spring Tool Suite). Because it helps a lot. Its do all configurations on its own. Additionally, use Hibernate with spring-boot as a database framework. With this combination, your application will be the best. I can guarantee that with my experiences.
Even this is one of the best frameworks for JEE(in present) this is gonna die in the near future. There are lightweight alternatives coming up. So keep updated with your experience don't stick to one particular framework. The best thing is being fluent in concepts, not in the frameworks.
Source: Stackoverflow.com