Configuring Jackson mapper when using Dropwizard Configuring Jackson mapper when using Dropwizard json json

Configuring Jackson mapper when using Dropwizard


JavaTimeModule is registered by default in Dropwizard 1.0.0 and above. For previous versions, the dropwizard-java8 bundle provided support for Java 8 features. Java 8 is the baseline for Dropwizard 1.0.0, and the bundle was merged into baseline.

Assuming you use Dropwizard 1.0.0 or above, if you still need to access the ObjectMapper, you can do it in your Application<T>:

  • in method void initialize(Bootstrap<T> bootstrap), via bootstrap.getObjectMapper()
  • in method abstract void run(T configuration, Environment environment), via environment.getObjectMapper()

That way, you can register other modules, or enable or disable Jackson features. Some of them impact how Java 8 types are serialized and deserialized.