是什么引起java.lang.NoSuchMethodError:com.fasterxml.jackson.core.JsonFactory.requiresPropertyOrdering()Z

时间:2019-07-11 19:51:06

标签: java maven jackson

环顾四周,查看此错误,看来问题出在同一个依赖项的版本不兼容。我有一个项目从另一个项目中调用一个类,因此我有两个单独的pom.xml,但它们都具有相同版本的jackson依赖关系,因此我不确定是什么导致了此错误。这是我的两个pom.xml:

pom.xml#1

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.microsoft.bingads</groupId>
    <version>12.13.3</version>
    <name>Bing Ads Java SDK</name>
    <description>The Bing Ads Java SDK is a library improving developer experience when working with the Bing Ads services by providing high-level access to features such as Bulk API, OAuth Authorization and SOAP API.</description>
    <url>https://github.com/BingAds/BingAds-Java-SDK</url>


    <distributionManagement>
        <snapshotRepository>
            <id>ossrh</id>
            <url>https://oss.sonatype.org/content/repositories/snapshots</url>
        </snapshotRepository>
    </distributionManagement>
    <dependencies>

<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<dependency>
    <groupId>com.fasterxml.jackson.dataformat</groupId>
    <artifactId>jackson-dataformat-xml</artifactId>
    <version>2.9.9</version>
</dependency>



        <dependency>
            <groupId>com.googlecode.jcsv</groupId>
            <artifactId>jcsv</artifactId>
            <version>1.4.0</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.11</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.easymock</groupId>
            <artifactId>easymock</artifactId>
            <version>3.2</version>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.3.2</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-ri</artifactId>
            <version>2.3.2</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-text</artifactId>
            <version>1.1</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>rt</artifactId>
            <version>2.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-frontend-jaxws</artifactId>
            <version>${cxf.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.cxf</groupId>
            <artifactId>cxf-rt-transports-http</artifactId>
            <version>${cxf.version}</version>
        </dependency>                
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpmime</artifactId>
            <version>${http.version}</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>${http.version}</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.bingads</groupId>
            <artifactId>microsoft.bingads</artifactId>
             <version>12.13.3</version>
        </dependency>
    </dependencies>
    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <cxf.version>3.3.2</cxf.version>
        <http.version>4.5.3</http.version>
    </properties>
    <artifactId>microsoft.bingads</artifactId>
</project>

和pom.xml#2

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

  <modelVersion>4.0.0</modelVersion>

  <groupId>com.google.api-ads.examples</groupId>
  <artifactId>adwords-axis-examples</artifactId>
  <version>4.6.0</version>

  <packaging>jar</packaging>

  <name>AdWords Examples using Axis</name>
  <description>
    This project contains examples of using the Ads APIs client library for Java
    with AdWords and the Apache Axis framework. Please see the README file for
    more information about how to use the library.
  </description>

  <properties>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <smokeMainClass>adwords.axis.v201809.basicoperations.GetCampaigns</smokeMainClass>
  </properties>


<dependencies>


  <!-- https://mvnrepository.com/artifact/org.apache.poi/poi -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>3.17</version>
</dependency>

<!-- https://mvnrepository.com/artifact/org.apache.poi/poi-ooxml -->
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>3.17</version>
</dependency>

    <!-- Ads client library dependencies -->
    <dependency>
      <groupId>com.google.api-ads</groupId>
      <artifactId>ads-lib</artifactId>
      <version>4.6.0</version>
    </dependency>
    <dependency>
      <groupId>com.google.api-ads</groupId>
      <artifactId>adwords-axis</artifactId>
      <version>4.6.0</version>
    </dependency>

    <!-- Third party dependencies -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core --><!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-core -->

<dependency>
    <groupId>com.fasterxml.jackson.core</groupId>
    <artifactId>jackson-core</artifactId>
    <version>2.9.9</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.dataformat/jackson-dataformat-xml -->




    <dependency>
      <groupId>com.beust</groupId>
      <artifactId>jcommander</artifactId>
      <version>1.48</version>
    </dependency>
    <dependency>
    <groupId>io.rest-assured</groupId>
    <artifactId>rest-assured</artifactId>
    <version>4.0.0</version>
    <scope>test</scope>
    </dependency>

    <!-- Configuration to use log4j for logging -->
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.16</version>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
      <version>1.7.7</version>
    </dependency>
  </dependencies>

  <profiles>
    <profile>
      <id>smoketest</id>
      <properties>
        <exec.mainClass>${smokeMainClass}</exec.mainClass>
      </properties>
    </profile>
  </profiles>
</project>

分别运行每个类时,它们都按预期进行编译和运行,但是当我从类a调用b.foo()时,标题出现错误。有什么想法吗?

2 个答案:

答案 0 :(得分:0)

您可以使用maven维护父模块和其他子模块的集成,并在父模块中添加依赖项,以便两个子模块都可以考虑。

答案 1 :(得分:0)

我深入研究了一些依赖项,发现其中一个正在使用您在表面上看不到的较低版本的Jackson。因此,如果您遇到此问题并且正在使用Eclipse,请通过“依赖关系层次结构”视图查看pom.XML,您应该能够看到不兼容的来源。