• zkclient中包引用不对,导致NoSuchMethodError


    Exception in thread "main" java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.(Ljava/lang/String;ILorg/apache/zookeeper/Watcher;Z)V
    at org.apache.curator.utils.DefaultZookeeperFactory.newZooKeeper(DefaultZookeeperFactory.java:29)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl$2.newZooKeeper(CuratorFrameworkImpl.java:169)
    at org.apache.curator.HandleHolder$1.getZooKeeper(HandleHolder.java:94)
    at org.apache.curator.HandleHolder.getZooKeeper(HandleHolder.java:55)
    at org.apache.curator.ConnectionState.reset(ConnectionState.java:219)
    at org.apache.curator.ConnectionState.start(ConnectionState.java:103)
    at org.apache.curator.CuratorZookeeperClient.start(CuratorZookeeperClient.java:188)
    at org.apache.curator.framework.imps.CuratorFrameworkImpl.start(CuratorFrameworkImpl.java:234)
    at com.github.ddth.zookeeper.ZooKeeperClient._connect(ZooKeeperClient.java:534)
    at com.github.ddth.zookeeper.ZooKeeperClient.init(ZooKeeperClient.java:656)
    at com.github.ddth.kafka.KafkaClient.init(KafkaClient.java:117)
    at org.apache.myfaces.blank.ConsumerDemo5.main(ConsumerDemo5.java:20)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
    @btnguyen2k
     
    Owner
    Hi nidonglin, for some reasons maven pull an old version of Apache Zookeeper which does not have this method. I'm checking on this issue.
    A workaround for now is to add Apache Zookeeper 3.4.6+ explicitly to your project.
     
     
            <dependency>
                <groupId>com.github.sgroschupf</groupId>
                <artifactId>zkclient</artifactId>
                <version>0.1</version>
                <exclusions>
                    <exclusion>
                        <groupId>org.apache.zookeeper</groupId>
                        <artifactId>zookeeper</artifactId>
                    </exclusion>
                </exclusions>
            </dependency>
     
    默认会引入zookeeper3.3.3.jar,但curator2.7.0会默认依赖zookeeper3.6.jar

  • 相关阅读:
    mongodb群集
    AtoS查看iOS Crash log中的16进制代码日志
    Info.plist 的字段解释
    IOS --关于粘贴板 ,剪切板 ,UILabel的复制
    UItableView 所有内容保存为图片
    ios 工程图片清理shell
    检查项目图片是否被使用
    ios 联网 在mac机器上进行抓包
    还在为不停build 烦恼么?看这里~~
    修复OS X的Finder中文档 打开方式中重复程序的问题
  • 原文地址:https://www.cnblogs.com/zhucezmf/p/8250465.html
Copyright © 2020-2023  润新知