It is always interesting and exciting task to compare two popular frameworks. This time the contenders are two of the most popular microservices frameworks in Java. In this tutorial I am going to compare the various aspects of Spring Boot and Dropwizard.
I have been working on Spring Boot for almost an year and completely inspired by the concepts of Spring Boot. Dropwizard is little older than spring boot in microservices field. Also it has gained good popularity among the community. I felt it is a wise decision to compare both the frameworks.
Spring Boot Vs Dropwizard
Here is the Table of Contents for this tutorial that explains the key difference between spring boot and dropwizard.
- Spring Boot and Dropwizard comparison table
- HTTP Servers
- REST API Support
- Persistence Support
- Dependency Injection (DI)
- Packaging WAR and JAR for deployment
1. Spring Boot and Dropwizard Comparison Table
This table summarizes the key differences between these two frameworks. The subsequent sections explains each difference with more explanation.
|HTTP||Tomcat (default), Jetty, Undertow||Jetty|
|REST API||Spring (default), JAX-RS||Jersey|
|JSON||Jackson, GSON, jason-simple||Jackson|
|Logging||Logback, Log4j, Log4j2, Slf4j, Apache Commons logging||Logback, Slf4j|
|Official Integrations||Multiple starter POMs for official integrations||Hibernate Validator, Guava, Apache HTTP Client, Jersey client, JDBI, Liquibase, Mustache, Freemarker, Joda time|
2. HTTP Servers
Spring Boot supports Tomcat, Jetty and Undertow as the servlet containers. If you are not specifying any of the servlet containers in the Maven dependency, then it takes Tomcat as the default server and add the embedded version of JAR file to the libraries. Spring Boot is more flexible on this aspect and leaves you to overwrite preferred http servers to be used. Here is the current version of containers support by Spring Boot:
Where as Dropwizard is more strict on convention over configuration approach and it is allowing application developer to use only Jetty as the servlet container. You don’t have any choice to change the server configurations.
3. REST APIs Support
By default, Spring Boot uses it’s own REST implementations instead of standard specifications. But, you can easily overwrite the implementations to use either JAX-RS or Jersey libraries.
Dropwizard uses JAX-RS based Jersey as the default and only REST libraries supported for writing your REST APIs. However, this is not a bottleneck and good to use the JAX-RS standard for your applications. If you are using the specification standard, it is easy to switch to any other implementations that uses the standard specifications.
Spring Boot supports wide variety of libraries for the logging mechanism. It offers Logback, Log4j, Log4j2, Slf4j and Apache Commons logging. By default, spring boot uses the Logback as the logging implementations. You can read our tutorial logging configurations for more understanding on how to use the logging with spring boot.
Where as Dropwizard supports Logback and Slf4j as the only two libraries that can be used for the logging mechanism.
Logback is the most preferred logging mechanism as of now. Before logback, most of the projects preferred using the Log4j as the logging mechanism. However, logback offers many improvements over log4j and there are several reasons to use it over log4. So, both the frameworks supports this implementation.
Metrics is one of the most important requirement for production applications. Without proper measurement we can not evaluate the performance of an application.
Dropwizard uses it’s own solution for the metrics display. One of the great advantage for using Dropwizard over spring boot is to utilize it’s advanced metrics solution.
Where as spring boot provides it’s own metrics and that are basic information compared to what is offered in Dropwizard. Even spring boot documentation recommends to use Dropwizard metrics for any advanced functionality.
6. Persistence Support
Dropwizard is very tightly coupled with Hibernate ORM Framework. Hibernate is compatible with JPA 2.1, but with dropwizard-hibernate you cannot inject EntityManager for example, and you have to use Hibernate’s Session and SessionFactory. This is clearly a limitation if you want to use any other ORM frameworks apart from the Hibernate.
Where as Spring Boot uses it’s own data abstraction framework Spring Data JPA. Spring Data module is written on JPA 2.1, so it is possible for us to use callback methods like prePersist, preUpdate, etc. Another good news is that Spring Boot works with many other ORMs other than Hibernate. It is not very easy to achieve in Dropwizard.
7. Dependency Injection (DI)
The main difference between both the frameworks is dependency injection support. Spring applications uses it’s own dependency management comes with the Spring Core module. However, Dropwizard doesn’t have out of the box solution for the dependency managements. You have to choose one of the solutions available in the market. Preferably you can use Google Guice.
8. Packaging JAR and WAR for Deployment
spring-boot-loader module in the spring boot supports executable jar and war files. Generating the
WAR file are supported out of the box by just adding the packaging as JAR or WAR in the Maven or Gradle build file. Both, WAR and JAR can be executed as the standalone service in your server. Also if you want to deploy in the application servers, the WAR can be used for that purpose. We are running several applications in the traditional application servers where we don’t need the executable JAR and we only require WAR file to deploy. Spring Boot helps you to generate your needs for the peaceful deployment.
Also spring boot uses the nested JAR files for creating the FAT JAR instead of shaded JARs. Nested JAR contains dependency JAR as another JAR file inside the FAT JAR. However, Shaded JAR package just adds all the class files inside the single JAR which would cause many issues if two libraries have same class names. Dropwizard uses the shaded JAR packaging.
Here is the structure of spring boot loader supported JAR file:
Here is the structure of spring boot loader supported WAR file:
If you look at the above structure, all the dependency JAR files are added inside the lib folder as the nested JAR files.
Dropwizard doesn’t officially supports the building of WAR file in it’s build file. It is against it’s concept of microservices. But, you can use one of the existing community module for building the WAR files. This is again a extra burden for the developers.
Dropwizard was initially released by Coda Hale in late 2011 back in his days at Yammer. Dropwizard have great community support but the release cycle are slow. In the initial period of it’s inception, the release cycles are much faster and every months new release was planned. But, most recently the releases are slower and also every release has more updates to the third party libraries then any update to the core framework updates.
Where as Spring has the strong support from Pivotal which owns the spring framework. Spring Boot first introduced on 2014 (just two years back), but since then they have added lots of official modules for most of the third party libraries. The release cycle is quicker and they add lots of exciting features for every new release. The latest release being 1.3.0, they have added new features on spring boot actuator and new module DevTools which improves the development time.
In this tutorial I have compared spring boot and dropwizard head to head with various parameters. Most of the parameters I have compared in this tutorial, spring boot shows more flexible than dropwizard. But, some of the parameters like Metrics (which is key for production applications), Dropwizard offers better functionality than spring boot.
If you are working on the spring based applications. Then, spring boot is the clear choice for you. It works very well for the spring applications. Otherwise, Dropwizard is the better choice for you. I hope you find this comparison useful and helped you to understand the difference between spring boot and dropwizard.
If you have any questions, please write it in the comments section. If you are looking for any help or support for implementing the Spring Boot applications, please drop a mail to us. We will get back to you with answers for your queries.
Thank you for reading my blog!! Happy Reading!!