Java
Switch branches/tags
jackson-module-jaxb-annotations-2.9.0.pr4 jackson-module-jaxb-annotations-2.9.0.pr3 jackson-module-jaxb-annotations-2.9.0.pr2 jackson-module-jaxb-annotations-2.9.0.pr1 jackson-module-jaxb-annotations-2.8.11 jackson-module-jaxb-annotations-2.8.10 jackson-module-jaxb-annotations-2.8.9 jackson-module-jaxb-annotations-2.8.8 jackson-module-jaxb-annotations-2.8.7 jackson-module-jaxb-annotations-2.8.6 jackson-module-jaxb-annotations-2.8.5 jackson-module-jaxb-annotations-2.8.4 jackson-module-jaxb-annotations-2.8.3 jackson-module-jaxb-annotations-2.8.2 jackson-module-jaxb-annotations-2.8.1 jackson-module-jaxb-annotations-2.8.0 jackson-module-jaxb-annotations-2.8.0.rc2 jackson-module-jaxb-annotations-2.8.0.rc1 jackson-module-jaxb-annotations-2.7.9 jackson-module-jaxb-annotations-2.7.8.1 jackson-module-jaxb-annotations-2.7.8 jackson-module-jaxb-annotations-2.7.7 jackson-module-jaxb-annotations-2.7.6 jackson-module-jaxb-annotations-2.7.5 jackson-module-jaxb-annotations-2.7.4 jackson-module-jaxb-annotations-2.7.3 jackson-module-jaxb-annotations-2.7.2 jackson-module-jaxb-annotations-2.7.1 jackson-module-jaxb-annotations-2.7.0 jackson-module-jaxb-annotations-2.7.0-rc3 jackson-module-jaxb-annotations-2.7.0-rc2 jackson-module-jaxb-annotations-2.7.0-rc1 jackson-module-jaxb-annotations-2.6.7 jackson-module-jaxb-annotations-2.6.6 jackson-module-jaxb-annotations-2.6.5 jackson-module-jaxb-annotations-2.6.4 jackson-module-jaxb-annotations-2.6.3 jackson-module-jaxb-annotations-2.6.2 jackson-module-jaxb-annotations-2.6.1 jackson-module-jaxb-annotations-2.6.0 jackson-module-jaxb-annotations-2.6.0-rc4 jackson-module-jaxb-annotations-2.6.0-rc3 jackson-module-jaxb-annotations-2.6.0-rc2 jackson-module-jaxb-annotations-2.6.0-rc1 jackson-module-jaxb-annotations-2.5.5 jackson-module-jaxb-annotations-2.5.4 jackson-module-jaxb-annotations-2.5.3 jackson-module-jaxb-annotations-2.5.2 jackson-module-jaxb-annotations-2.5.1 jackson-module-jaxb-annotations-2.5.0 jackson-module-jaxb-annotations-2.5.0-rc1 jackson-module-jaxb-annotations-2.4.6 jackson-module-jaxb-annotations-2.4.5 jackson-module-jaxb-annotations-2.4.4 jackson-module-jaxb-annotations-2.4.3 jackson-module-jaxb-annotations-2.4.2 jackson-module-jaxb-annotations-2.4.1 jackson-module-jaxb-annotations-2.4.0 jackson-module-jaxb-annotations-2.4.0-rc3 jackson-module-jaxb-annotations-2.4.0-rc2 jackson-module-jaxb-annotations-2.3.5 jackson-module-jaxb-annotations-2.3.4 jackson-module-jaxb-annotations-2.3.3 jackson-module-jaxb-annotations-2.3.2 jackson-module-jaxb-annotations-2.3.1 jackson-module-jaxb-annotations-2.3.0 jackson-module-jaxb-annotations-2.3.0-rc1 jackson-module-jaxb-annotations-2.2.4 jackson-module-jaxb-annotations-2.2.3 jackson-module-jaxb-annotations-2.2.2 jackson-module-jaxb-annotations-2.2.1 jackson-module-jaxb-annotations-2.2.0 jackson-module-jaxb-annotations-2.2.0-rc1 jackson-module-jaxb-annotations-2.1.5 jackson-module-jaxb-annotations-2.1.3 jackson-module-jaxb-annotations-2.1.2 jackson-module-jaxb-annotations-2.1.1 jackson-module-jaxb-annotations-2.1.0 jackson-module-jaxb-annotations-2.0.6 jackson-module-jaxb-annotations-2.0.5 jackson-module-jaxb-annotations-2.0.4 jackson-module-jaxb-annotations-2.0.3 jackson-module-jaxb-annotations-2.0.2 jackson-module-jaxb-annotations-2.0.1 jackson-module-jaxb-annotations-2.0.0 jackson-module-jaxb-annotations-2.0.0-RC3 jackson-module-jaxb-annotations-2.0.0-RC2 jackson-module-jaxb-annotations-2.0.0-RC1 2.5.3b 2.1.4b
Nothing to show
Clone or download

README.md

NOTE: This module has become part of Jackson Base Modules repo. as of Jackson 2.9

This repo still exists to allow release of patch versions of older versions; it will be hidden (made private) in near future.


Overview

This Jackson extension module provides support for using JAXB (javax.xml.bind) annotations as an alternative to native Jackson annotations. It is most often used to make it easier to reuse existing data beans that used with JAXB framework to read and write XML.

Maven dependency

To use this extension on Maven-based projects, use following dependency:

<dependency>
  <groupId>com.fasterxml.jackson.module</groupId>
  <artifactId>jackson-module-jaxb-annotations</artifactId>
  <version>2.4.0</version>
</dependency>

(or whatever version is most up-to-date at the moment)

Usage

To enable use of JAXB annotations, one must add JaxbAnnotationIntrospector provided by this module. There are two ways to do this:

  • Register JaxbAnnotationModule, or
  • Directly add JaxbAnnotationIntrospector

Module registration works in standard way:

JaxbAnnotationModule module = new JaxbAnnotationModule();
// configure as necessary
objectMapper.registerModule(module);

and the alternative -- explicit configuration is done as:

AnnotationIntrospector introspector = new JaxbAnnotationIntrospector();
// if ONLY using JAXB annotations:
mapper.setAnnotationIntrospector(introspector);
// if using BOTH JAXB annotations AND Jackson annotations:
AnnotationIntrospector secondary = new JacksonAnnotationIntrospector();
mapper.setAnnotationIntrospector(new AnnotationIntrospector.Pair(introspector, secondary);

Note that by default Module version will use JAXB annotations as the primary, and Jackson annotations as secondary source; but you can change this behavior