The port settings of the Jetty server can also be done via the configuration file.

      - type: http
        port: 18080

      - type: http
        port: 18081


The logging of the server and services is also done via the configuration file.

    timeZone: UTC
      - type: file
        currentLogFilename: /var/log/areacodes/access.log
        threshold: ALL
        archive: true
        archivedLogFilenamePattern: /var/log/areacodes/access.%d.log.gz
        archivedFileCount: 14

  level: INFO

    - type: console
      threshold: WARN
      target: stderr

    - type: file
      currentLogFilename: /var/log/areacodes/broker.log
      archivedLogFilenamePattern: /var/log/areacodes/broker.%d.log.gz
      archivedFileCount: 14
      timeZone: UTC


The Metrics library is used to get an insight view into the running server.

Adding additional metrics

To add additional metrics a MetricRegistry is needed. It can be obtained during the bootstrap phase.

public void initialize(Bootstrap<PostalCodeConfiguration> bootstrap) {
    metricRegistry = bootstrap.getMetricRegistry();


Adding additional HTML pages

If you want to add additional HTML pages (like a welcome page) then you can do this in the initialize method of the Application class.

Found on Stackoverlow Configure dropwizard to server index.html for (almost) all routes?

I've done this without changing my configuration. In fact, it only took me one line of code, to be put in the initialize method of my Application class:

bootstrap.addBundle(new AssetsBundle("/app", "/", "index.html", "static"));

Which basically says to serve anything under /app inside my JAR file under the URL pattern /, with index.html as the default file. This bundle will be named static, but you could pick whatever name you like.

Note that I'm using version 0.7.0-rc2 of Dropwizard, I'm not sure whether it works for earlier versions as well.


Jackson is used for de-/serialization of the data.

@JsonProperty is used to annotate field or method for serialization.

If a field should be ignored during the serialization process the annotation @JsonIgnore can be used or the field can be marked as transient.


Swagger can be used to document the REST services registered the dropwizard instance.

Add Maven Dependency


Register Swagger UI

private final SwaggerDropwizard swaggerDropwizard = new SwaggerDropwizard();

public void initialize(Bootstrap<TestConfiguration> bootstrap) {

public void run(TestConfiguration configuration, Environment environment) throws Exception {
    swaggerDropwizard.onRun(configuration, environment);

Annotate Resources

Swagger only scans resources which have an @Api annotation on them. Resources need to be annotated to be listed by swagger.

Annotate Methods

At least one method must be annotated for the resource to be visible for swagger.