Skip to content

Using Jackson2 with Maven

Tatu Saloranta edited this page May 19, 2013 · 2 revisions

Jackson 2.x is divided into a fairly large collection of artifacts to allow fine-grained dependency management. These are published to Maven Central under several different Maven groupId values, which can make it hard to find them in search.maven.org. The following is a set of Maven dependency declarations for the most common components, with some comments. In all cases here, ${jackson-2-version} is presumed to be a property set to the version you want to use.

 <!-- the core, which includes Streaming API, shared low-level abstractions (but NOT data-binding) -->
 <dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-core</artifactId>
   <version>${jackson-2-version}</version>
 </dependency>

 <!-- Just the annotations; use this dependency if you want to attach annotations
      to classes without connecting them to the code. -->
 <dependency>
   <groupId>com.fasterxml.jackson.core</groupId>
   <artifactId>jackson-annotations</artifactId>
   <version>${jackson-2-version}</version>
</dependency>

<!-- databinding; ObjectMapper, JsonNode and related classes are here -->
<dependency>
  <groupId>com.fasterxml.jackson.core</groupId>
  <artifactId>jackson-databind</artifactId>
  <version>${jackson-2-version}</version>
</dependency>

<!-- smile (binary JSON). Other artifacts in this group do other formats. -->
<dependency>
  <groupId>com.fasterxml.jackson.dataformat</groupId>
  <artifactId>jackson-dataformat-smile</artifactId>
  <version>${jackson-2-version}</version>
</dependency>
<!-- JAX-RS provider -->
<dependency>
   <groupId>com.fasterxml.jackson.jaxrs</groupId>
   <artifactId>jackson-jaxrs-json-provider</artifactId>
   <version>${jackson-2-version}</version>
</dependency>
<!-- Support for JAX-B annotations as additional configuration -->
<dependency>
  <groupId>com.fasterxml.jackson.module</groupId>
  <artifactId>jackson-module-jaxb-annotations</artifactId>
  <version>${jackson-2-version}</version>
</dependency>