本文介绍了Apache Curator TestingServer创建会抛出java.lang.NoSuchMethodError的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试仅运行TestingServer以便能够为其编写单元测试.

I am trying to just run a TestingServer to be able to write unit tests for it.

    val zkServer = new TestingServer(2182)
    println(zkServer.getPort)

我的pom具有以下与Curator相关的依赖项,我尝试了4.2.0和4.3.0版本,都抛出相同的错误:

My pom has the following dependencies related to Curator, I have tried version 4.2.0 and 4.3.0, both throw the same error:

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-framework</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>


    <!-- https://mvnrepository.com/artifact/org.apache.curator/curator-recipes -->
    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-recipes</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>

    <dependency>
        <groupId>org.apache.curator</groupId>
        <artifactId>curator-test</artifactId>
        <version>${apache.curator.version}</version>
    </dependency>

抛出的错误是这样的:

Exception in thread "Thread-0" java.lang.NoSuchMethodError: org.apache.zookeeper.server.ZooKeeperServer.<init>(Lorg/apache/zookeeper/server/persistence/FileTxnSnapLog;IIILorg/apache/zookeeper/server/ZKDatabase;)V
at org.apache.curator.test.TestingZooKeeperMain$TestZooKeeperServer.<init>(TestingZooKeeperMain.java:265)
at org.apache.curator.test.TestingZooKeeperMain.internalRunFromConfig(TestingZooKeeperMain.java:226)
at org.apache.curator.test.TestingZooKeeperMain.runFromConfig(TestingZooKeeperMain.java:132)
at org.apache.curator.test.TestingZooKeeperServer$1.run(TestingZooKeeperServer.java:158)
at java.lang.Thread.run(Thread.java:748)

推荐答案

我认为Curator目前仅与zookeeper 3.5.x兼容.我试图用3.6.0来运行它.因此,切换到3.5.x的问题为我解决了该问题.

I think Curator is only compatible with zookeeper 3.5.x right now. I was trying to run it with 3.6.0. Hence the problem switching to 3.5.x fixed the issue for me.

这篇关于Apache Curator TestingServer创建会抛出java.lang.NoSuchMethodError的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 13:44