如何修复log4j中的“NoSuchMethodError”错误

30byixjq  于 2022-11-06  发布在  其他
关注(0)|答案(1)|浏览(231)

我正在开发一个使用elasticsearch的java应用程序。我在java中使用elasticsearch api。我得到NoSuchMethodError错误:
java.lang.NoSuchMethodError:如果您想在一个文件中记录日志,请点击这里。语言/对象;)V型
我已经包含了我的pom文件

<dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>

    <dependency>
        <groupId>org.elasticsearch.client</groupId>
        <artifactId>transport</artifactId>
        <version>5.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.elasticsearch</groupId>
        <artifactId>elasticsearch</artifactId>
        <version>5.4.2</version>
    </dependency>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>3.2.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.3</version>
    </dependency>
    <dependency>
        <groupId>commons-configuration</groupId>
        <artifactId>commons-configuration</artifactId>
        <version>1.10</version>
    </dependency>

    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.3</version>
    </dependency>
</dependencies>
gwbalxhn

gwbalxhn1#

请检查您对类路径的Log4j依赖性。对于elasticsearch 5.4.x,您需要Log4j 2.8.2(api和core),而不是2.3。请参阅https://www.elastic.co/guide/en/elasticsearch/client/java-api/5.4/_log4j_2_logger.html

相关问题