Skip to main content

Building a REST service with Dropwizard

We have already built the REST service using Spring Boot. You can find the article here – Building a simple REST Service with Spring Boot). Now I’ll explain how to build a REST service using Dropwizard.

Dropwizard is a simple, light-weight Java framework for developing DevOps friendly, High-performance REST web service.

What you will need

Step By Step

1.) Create a new Maven project.


2.)  Give GroupId and ArtifcatId.


3.) Give project name as “dropwizard-demo“.


4.) Create two packages as following (com.mydevgeek.config & com.mydevgeek.resources).


5.) Add dropwizard dependency into the pom.xml


6.) Create the class for containing configuration.


7.) Then create the class as the main class. This will be application’s main entry point.


8.) Now we’re going to create our REST controller. Create a class in the com.mydevgeek.resource package.


9.) Now we have to register the PersonResource class in the AppService class. Add the following line into the run() in the AppService class. Finally, it looks like this.


Run on IntelliJ

  • Click on Build ->Build Project.
  • Then click on Rub -> Edit Configurations…
  • The “Main class” would be com.mydevgeek.config.AppService and “Program Arguments” would be “server”.

  • Finally, click on the Run -> Run AppService.


Run on Command Line

Building Fat JAR

The concept is, contain all of .class file in the single .jar. The Dropwizard team recommends this method. For that, we need to add following plugin into the pom.xml. You have to add application’s main class between <mainClass> tags.


Versioning your JARs

This plugin use for jar versioning. This feature very helpful when needs to identify the version of your application that deployed on a server.


Finally, pom.xml looks like this.

Then use following commands to build and run on the console.


How to test it

Use POSTMAN to test REST api.

Download code :- GitHub

Related Post

4090total visits,9visits today

Follow by Email