jersey and jackson maven dependency issues?

后端 未结 3 1827
粉色の甜心
粉色の甜心 2021-01-20 18:44

I have just started building a web app using jersey and jackson. After initially getting up and running I decided that it made sense in the long run to convert the project t

相关标签:
3条回答
  • 2021-01-20 19:11

    The jersey-json dependencies have its own jackson dependency.

    For Jersey 1.8 its Jackson 1.7.1. So, start by removing the 1.8.1 and 1.8.2 dependencies, they may cause trouble. Maven is not deterministic: if it encounters two versions of the same dependency (with the same count), the chosen one cannot be predicted.

    You don't have to create a JSON string neither to call Jackson mapper yourself. Take a look a this fully working/tested app I've post on GitHub. Hope it will help.

    0 讨论(0)
  • 2021-01-20 19:14

    As already mentioned, this is probably a version conflict (error message does suggest that something is compiled against 1.8, but an earlier version is being used somehow).

    One thing that I have noticed to cause issues is that versions of "core" and "mapper" jars may differ. In this case, for example, it sounds like mapper version 1.8 was being used, but core jar version was earlier. Although Jackson core jar does define proper version, Maven may not rely on that information but by version some other component mandates.

    So whenever specifying dependency to Jackson from your own pom.xml, make sure that versions of core (jackson-asl-core) and mapper (jackson-ask-mapper) are both defined, and have same value (or at least same minor versions, 1.8.x).

    0 讨论(0)
  • 2021-01-20 19:21

    I was having the same issue after I upgraded the datanucleus-hbase lib.

    My solution was to include the two jackson libs:

            <dependency>
            <groupId>org.datanucleus</groupId>
            <artifactId>datanucleus-hbase</artifactId>
            <version>3.1.0-m1</version>
        </dependency>
    
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-core-asl</artifactId>
            <version>1.9.4</version>
        </dependency>
    
        <dependency>
            <groupId>org.codehaus.jackson</groupId>
            <artifactId>jackson-mapper-asl</artifactId>
            <version>1.9.4</version>
        </dependency>
    
    0 讨论(0)
提交回复
热议问题