Apache Curator TestingServer 创建抛出 java.lang.NoSuchMethodError

Apache Curator TestingServer creation throws java.lang.NoSuchMethodError

我正在尝试 运行 一个 TestingServer 以便能够为其编写单元测试。

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

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

    <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.run(TestingZooKeeperServer.java:158)
at java.lang.Thread.run(Thread.java:748)

我认为 Curator 目前仅与 zookeeper 3 兼容。5.x。我试图用 3.6.0 运行 它。因此问题切换到 3。5.x 为我解决了这个问题。