Jackson ObjectMapper() constructor throws NoSuchMethod

后端 未结 9 1798
忘掉有多难
忘掉有多难 2020-12-09 03:40

I\'m using Jackson sample code to deserialize a POJO:

ObjectMapper m = new ObjectMapper();

This line throws a NoSuchMethodError:

         


        
相关标签:
9条回答
  • 2020-12-09 04:03

    The trick here is to exclude jackson from the dependencies that use it.

    To check which dependencies import it, you can use the following maven command:

    mvn dependency:tree -Dincludes=org.codehaus.jackson

    0 讨论(0)
  • 2020-12-09 04:09

    In my case it was due to yammer-metrics library including an older version of jackson.

    <dependency>
      <groupId>com.yammer.metrics</groupId>
      <artifactId>metrics-servlet</artifactId>
      <version>2.1.2</version>
        <exclusions>
            <exclusion>
                <groupId>org.codehaus.jackson</groupId>
                <artifactId>jackson-mapper-asl</artifactId>
            </exclusion>
        </exclusions>
    </dependency>
    
    0 讨论(0)
  • 2020-12-09 04:10

    I had this same problem. The core jar was 1.7.1 while the mapper was 1.8.1. Note: To fix this for maven I added an exclusion and pulled down the proper version.

            <exclusions>
                <exclusion>
                    <groupId>org.codehaus.jackson</groupId>
                    <artifactId>jackson-mapper-asl</artifactId>
                </exclusion>
            </exclusions>
    
    0 讨论(0)
提交回复
热议问题