今天启动 连接 zookeeper时,报如下错误:

Exception in thread "main" java.lang.NoSuchMethodError: org.apache.zookeeper.ZooKeeper.<init>(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:213)
	at org.apache.curator.HandleHolder$1.getZooKeeper(HandleHolder.java:100)
	at org.apache.curator.HandleHolder.getZooKeeper(HandleHolder.java:48)
	at org.apache.curator.ConnectionState.reset(ConnectionState.java:204)
	at org.apache.curator.ConnectionState.start(ConnectionState.java:111)
	at org.apache.curator.CuratorZookeeperClient.start(CuratorZookeeperClient.java:237)
	at org.apache.curator.framework.imps.CuratorFrameworkImpl.start(CuratorFrameworkImpl.java:338)
	at com.xuan.rpc.registry.impl.ZookeeperRegistryHandler.<init>(ZookeeperRegistryHandler.java:53)
	at com.xuan.rpc.ServerBootstrap.main(ServerBootstrap.java:34)

原因:

     之前使用 zkClient连接的zookeeper,现在改为了 Curator ,启动时报此问题

解决办法:

在pom.xml中去掉zkClient的依赖

<!--<dependency>-->
            <!--<groupId>com.101tec</groupId>-->
            <!--<artifactId>zkclient</artifactId>-->
            <!--<version>0.2</version>-->
        <!--</dependency>-->

 

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐