121

For a large company (web) project, do you recommend using Spring MVC or Spring-Boot?

Spring-Boot, in terms of configuration, is very easy compared to Spring MVC.

I wonder if I use Spring-Boot can have the same advantages of Spring MVC?

What do you recommend?

nbro
  • 15,395
  • 32
  • 113
  • 196
Diego
  • 2,395
  • 2
  • 21
  • 27
  • 29
    The choice is not *between* MVC and Boot because Boot [can use MVC (and autoconfigure it)](http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/#boot-features-spring-mvc). If you mean "Boot or Boot-less?" then it depends on how open to innovation (and associated risks) your company is. Either way, [asking for recommendation *is* off-topic](http://stackoverflow.com/help/dont-ask) here. – kryger Apr 06 '15 at 21:53
  • Thank you for your response. I realized that spring boot can be configured to spring mvc. But I am confused whether to use Spring-Boot or Spring MVC both have the same characteristics (Spring boot easy to set up). From your experience as you use? – Diego Apr 07 '15 at 07:12
  • 1
    Spring boot save your time to configure an application have default beans and manage the dependencies too. But, spring-boot and spring-mvc have different goals. If you want to use spring-boot with spring-mvc you can and you don't need to setup anything unless you want to override custom configuration. – Eddú Meléndez Apr 07 '15 at 23:01
  • Thank you for your response. For my future project will use Spring -Boot . I think Spring -Boot is easier to configure and save a lot of time . – Diego Apr 09 '15 at 08:45
  • 2
    And spring boot is not incompatible with a war packaging and a external servlet container, see [58.2 Packaging executable jar and war files](https://spring.io/guides/gs/convert-jar-to-war/) – Nicolas Labrot Apr 10 '15 at 10:40
  • Thanks for your response. I will certainly use Spring -Boot for a web project . Spring -Boot eliminates all code xml . I hope that in future we will use this form to all projects and eliminate .xml configurations that are very annoying and incomprehensible for large web projects . – Diego Apr 10 '15 at 12:08
  • so finally, you run the fat jar or create war file :). I did simple wrk test, then deploy war file on wildfly run 20% faster than spring fat jar – Thang Hoang Dec 16 '15 at 03:09
  • Spring MVC doesn't require XML configuration, but some dependencies might. http://docs.spring.io/spring/docs/current/spring-framework-reference/html/beans.html#beans-java – ben3000 Dec 19 '15 at 02:55
  • The question might be to use Spring Boot or not into a Spring project, which I would definitelly answer as a 'yes' for a new project. But Boot and MVC are themselves fully compatible. [This answer](http://stackoverflow.com/questions/32922914/difference-between-spring-mvc-and-spring-boot/32923000#32923000) explain their differences. – Aritz Jan 20 '17 at 10:00
  • Have to check this, https://stackoverflow.com/a/52232727/9437031 – Dhwanil Patel Sep 06 '20 at 14:30

5 Answers5

108

My personal advice is to definitely use Spring Boot for many reasons.

  1. The first is that Boot is the "future of Spring". That means that with Boot you can benefit from many commitments of the Spring community. Most of the Spring projects today are completely integrated with Boot, even the community starts to develop many applications based on Boot. For example for managing and monitoring. I can suggest to see Spring Boot Admin

  2. With Spring Boot you can benefit from very nice and useful features such as actuator and remote shell for managing and monitoring, that improves your application with production ready features that are very useful.

  3. Very nice and powerful properties and configuration controls - you can configure your application with application.properties/yml and extend the boot in a very simple and impressive way, even the management in terms of overriding is very powerful.

  4. It is one of the first micro-service ready platforms, and in my opinion nowadays it is the best! Even if you don't build a micro-service project with boot you can benefit of using a modern approach in which you have a auto-consistent jar that can benefit from all the features that I described above or if you prefer you can impose the packaging as a classical war and deploy your war in any of the containers that you want.

  5. Use of an intelligent and convention over configuration approach that reduces the startup and configuration phase of your project significantly. In fact you have a set of starter Maven or Gradle dependencies that simplify the dependency management. Then with the auto-configuration characteristic you can benefit from a lot of standard configurations, that are introduced through the Conditional Configuration framework in Spring 4. You can override it with your specific configurations just defining your bean according with the convention that you can see in the auto-configure JAR of the Boot dependency. Remember that Spring is open-source and you can see the code. Also the documentation in my opinion is good.

  6. Spring initializer is a cool tool attainable at this link: https://start.spring.io/ is a very cool tool just to create your project in a very fast way.


I hope that this reflection can help you decide what is the best solution.

coconut
  • 494
  • 2
  • 5
  • 13
Valerio Vaudi
  • 4,199
  • 2
  • 24
  • 23
  • 1
    Thank you for the answer. I have a little confusion here. I want to use Spring 4 in my project as I wont have to use `persistence.xml` configuration file and many other features. Can I have spring 4's features in spring boot? If yes how to do that – viper May 19 '16 at 04:24
  • 2
    I would tend to agree if you're planning on doing things pretty vanilla. The amount of times I've attempted to go to boot cause headache and me yelling at the screen because boot tries to be too smart about what dependencies I have and end up having to do more to turn things off than I would to turn things on using a bootless project. A couple things that end up nightmarish is trying to work with LDAP where a db cache is needed, or configuring more than one DataSource has boot trying to create JdbcTemplate and hibernate instances without me knowing, and even starting the h3 database by itself. – Brett Ryan May 24 '16 at 07:21
  • 1
    Property configuration is also something I haven't worked out how to control. In bootless projects I would create an AppConfig class that has overloaded support for reading properties in my apps properties file that I can use in JSP's and SpEL but can't figure out how to do the same with boot. – Brett Ryan May 24 '16 at 07:24
  • What is an auto-consistent JAR? – phant0m Jul 19 '16 at 15:49
  • When I talk about auto consisten jar I refer to the capability of srping boot of pakage the your app in a jar that have all the necessary for your app. In fact if your app is a stand alone app you can put the init configuration in the CommandLineRunner run method when if your app is a web-app boot will pakage your application with a embedded servlet container in a sipmle configuration way through application.properties file, thanks at the capability of redifine the application properties with env prop, jvm paramiter and so on – Valerio Vaudi Jul 19 '16 at 18:49
  • 1
    Is this answer still valid (six-month later) I am looking into this, and I still dont understand why would people still use Spring, when they have the awesome Spring Boot? I mean I like Spring Boot very much, the idea of intelligent software that configures itself is very much awesome to me but I am very confused! again **why would people still use Spring, when they have the awesome Spring Boot?** – Ahmad Hajjar Sep 08 '16 at 15:06
  • 1
    @AhmadHajjar, for a new project I would definitelly go with Spring Boot. Currently it's a completely mature tool. But keep in mind people need still to maintain plain Spring projects, some of them might be straight forward to move to Boot and others probably are so big that would make the migration process a pain. – Aritz Jan 20 '17 at 09:56
  • Spring boot provides autoconfiguration. But this is helpful in very few cases. As in example, many large scale application does not use the default configuration, eg; to configure MongoDB. We need our explicit configuration. Also any Spring MVC can be initialized with start-up.jar. I think both Spring MVC and Spring Boot are similar. But definatly Spring Boot is build on top of Spring MVC. – Abhishek Oct 23 '17 at 07:43
41

Spring Boot uses Spring MVC! It's just autoconfigured and ready to use when you import the spring-boot-starter-web jar. So you'd basically are talking about whether to use Spring Boot or manually setup your Spring Application...

Ulises
  • 9,115
  • 2
  • 30
  • 27
  • 4
    Yep _+1, Spring boot is just autoconfiguration tool, Spring mvc is web framework – Plain_Dude_Sleeping_Alone Sep 14 '16 at 21:51
  • @Plain_Dude_Sleeping_Alone I understand that Spring MVC is a framework. You say Spring Boot is just a autoconfig tool, can it also be considered as a Framework? – JayC Aug 03 '17 at 14:52
  • @Jesse, well both of them can be considered as either tools or frameworks. But what people empashize here is that spring boot is rather a tool for the Spring mvc web framework. It will provide a ready-configuration needed for the Spring mvc, though, the booty itself is in a form of framework. Finally, my english is so bad that it may already burn your face. Hehe – Plain_Dude_Sleeping_Alone Aug 04 '17 at 12:04
  • I agree to this and I will definetly use spring boot to do better with less work – Ronit Pandey Aug 01 '23 at 08:15
24

You can definitely go for Spring Boot. We have already started using Spring Boot for building enterprise application. It has lot of advantages, listing few below here:

  1. Your project configuration will be pretty simple. No need to maintain XML file, all you need to know is how efficiently you can use application.properties file.

  2. Gives lot of default implementation, for instance if you need to send an email, it provides default implementation of JavaMailSender

  3. Spring Hibernate and JPA integration will be pretty simple.

Like this there are many, you can explore based on your needs.

informatik01
  • 16,038
  • 10
  • 74
  • 104
Rakesh
  • 1,374
  • 1
  • 16
  • 24
  • Spring boot is always preferred because you don't have to deal with verbose XML and they leverage micro-services architectures – Jorge Tovar Jun 11 '19 at 17:22
10

You can use Spring MVC with spring boot as @kryger said, they are non exclusive between them, and the configuration will be easier, also I recommend you to use http://www.thymeleaf.org/ which is template framework. Working with that is like working with JSP but thymeleaf integrates seamlessly with HTML, so your code will look very clean and you can add a lot of useful features.

aruiz
  • 165
  • 1
  • 11
9

I think Spring Boot is more useful than the MVC, as it has many advantages and inbuilt features which make it more reliable than MVC. In Spring Boot most of the things are auto configured and there is no need of writing those xml as we do in the MVC, which can save time.

Spring Boot bundles a war file with server run-time like Tomcat. This allows easy distribution and deployment of web applications. As the industry is moving towards container based deployments, Spring Boot is useful in this context as well.

Spring MVC is web application framework. While you can do everything in Spring without Spring Boot, but Spring Boot helps you get things done faster.

Spring boot simplifies your Spring dependencies, no more version collisions, can be run straight from a command line without an application container, build more with less code - no need for XML, not even web.xml, auto-configuration, useful tools for running in production, database initialization, environment specific config files, collecting metrics.

Basics of Spring Boot can be found here

Muhammad Waqas Dilawar
  • 1,844
  • 1
  • 23
  • 34
Sanket
  • 355
  • 5
  • 14
  • Thank you for the answer. It was very helpful for understanding about spring boot. One thing I am confused about is, if I will have to change the spring version that I am using, how would I do that with spring boot? I cannot see anywhere where spring version is defined. – viper Oct 18 '16 at 07:15
  • Did not use maven in your project? @viper – erginduran May 12 '17 at 07:45
  • yes i have used maven. but using spring boot, i cannot see the spring dependencies there. – viper May 12 '17 at 07:48