Apache Curator ZooKeeper单元测试产生错误
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Apache Curator ZooKeeper单元测试产生错误相关的知识,希望对你有一定的参考价值。
我正在尝试使用Apache Curator库编写ZooKeeper的单元测试。我正在使用策展人测试的Maven依赖项。我的代码如下:
final TestingCluster testingCluster = new TestingCluster(3);
testingCluster.start();
但是我收到此错误:
Exception in thread "Thread-0" java.lang.NoSuchFieldError: configFileStr
at org.apache.curator.test.QuorumConfigBuilder$1.<init>(QuorumConfigBuilder.java:142)
at org.apache.curator.test.QuorumConfigBuilder.buildConfig(QuorumConfigBuilder.java:137)
at org.apache.curator.test.TestingZooKeeperServer$1.run(TestingZooKeeperServer.java:157)
at java.lang.Thread.run(Thread.java:748)
我已经尝试将策展人版本与ZooKeeper版本进行多种组合。目前,我正在使用以下Maven依赖项:
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-client</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-async</artifactId>
<version>4.3.0</version>
<exclusions>
<exclusion> <!-- declare the exclusion here -->
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.zookeeper/zookeeper -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.13</version>
</dependency>
非常感谢您的帮助!
答案
[我注意到您没有从食谱依赖关系中排除ZooKeeper。另外,您只显示部分pom。你读过这份文件吗? http://curator.apache.org/zk-compatibility.html-请参阅“使用ZooKeeper 3.4.x测试”部分。
以上是关于Apache Curator ZooKeeper单元测试产生错误的主要内容,如果未能解决你的问题,请参考以下文章
Apache Curator ZooKeeper - KeeperErrorCode =未实现,错误
Apache Curator操作zookeeper的API使用
15. 使用Apache Curator管理ZooKeeper