12

Spring Boot already contains the core Jackson dependency + several others.

If you e.g. want to add the org.json or jsr-353 databinding modules you to explicitly define the vesion of these additional modules.

Is there a way to refer to the same version of the other Jackson modules? I want to avoid any compatibility issues.

Marcel Overdijk
  • 11,041
  • 17
  • 71
  • 110

3 Answers3

15

Spring Boot provides managed dependencies for the following Jackson modules:

  • jackson-annotations
  • jackson-core
  • jackson-databind
  • jackson-datatype-joda
  • jackson-datatype-jsr310

If you're using maven then additional modules could be defined in your own POM using the ${jackson.version} property. eg:

<dependency>
    <groupId>com.fasterxml.jackson.datatype</groupId>
    <artifactId>jackson-datatype-whatever</artifactId>
    <version>${jackson.version}</version>
</dependency>
Phil Webb
  • 8,119
  • 1
  • 37
  • 37
  • 1
    For Gradle users, if you use the Spring Boot Gradle plugin you can omit the version number to adopt the dependencies managed by Spring Boot, such as those Jackson modules listed above by Phil Webb. (See Spring Boot ref manual > 13. Build systems > [13.3 Gradle](http://docs.spring.io/spring-boot/docs/current-SNAPSHOT/reference/htmlsingle/#using-boot-gradle)). – Neil Brown Jul 10 '16 at 12:52
8

In Gradle just add ext['jackson.version'] = 'specify version here' before dependencies section.

Valeriy K.
  • 2,616
  • 1
  • 30
  • 53
2

Specify your dependencies explicitly and remove dependencies that you don't need as in:

<!-- Add typical dependencies for a web application -->
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <artifactId>jackson-databind</artifactId>
                <groupId>com.fasterxml.jackson.core</groupId>
            </exclusion>
        </exclusions>
    </dependency>
    <dependency>
        <groupId>org.json</groupId>
        <artifactId>json</artifactId>
        <version>20131018</version>
    </dependency>
</dependencies>

You can also change the version of built-in libs by overriding the properties. A list of properties can be found by looking at properties from effective POM using the command below. You can find the property which @Phil Web mentioned in the effective POM.

mvn help:effective-pom 
randominstanceOfLivingThing
  • 16,873
  • 13
  • 49
  • 72