使用 curator 结合zookeeper  发现报错

使用环境:xml

	        <dependency>
			<groupId>org.apache.zookeeper</groupId>
			<artifactId>zookeeper</artifactId>
			<version>3.5.7</version>
		</dependency>
<dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>4.0.0</version>
</dependency>

控制台信息:

log4j:WARN No appenders could be found for logger (org.apache.zookeeper.ZooKeeper).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
key:com.julong.rpc.service.HelloService
org.apache.zookeeper.KeeperException$UnimplementedException: KeeperErrorCode = Unimplemented for /register/com.julong.rpc.service.HelloService/127.0.0.1:8888
注册服务成功:com.julong.rpc.service.HelloService->127.0.0.1:8888
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:106)
	at org.apache.zookeeper.KeeperException.create(KeeperException.java:54)
	at org.apache.zookeeper.ZooKeeper.create(ZooKeeper.java:1637)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1189)
	at org.apache.curator.framework.imps.CreateBuilderImpl$17.call(CreateBuilderImpl.java:1166)
	at org.apache.curator.connection.StandardConnectionHandlingPolicy.callWithRetry(StandardConnectionHandlingPolicy.java:64)
	at org.apache.curator.RetryLoop.callWithRetry(RetryLoop.java:100)
	at org.apache.curator.framework.imps.CreateBuilderImpl.pathInForeground(CreateBuilderImpl.java:1163)
	at org.apache.curator.framework.imps.CreateBuilderImpl.protectedPathInForeground(CreateBuilderImpl.java:603)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:593)
	at org.apache.curator.framework.imps.CreateBuilderImpl.forPath(CreateBuilderImpl.java:47)
	at com.julong.rpc.zookeeper.service.impl.RegisterCenterServiceImpl.register(RegisterCenterServiceImpl.java:50)
	at com.julong.rpc.RpcServer.publisher(RpcServer.java:89)
	at com.julong.rpc.main.ServerDemo.main(ServerDemo.java:22)

这个是因为 curator 版本与zookeeper 兼容问题,将curator 版本降低 再进行尝试

测试通过版本 2.13.0

Logo

权威|前沿|技术|干货|国内首个API全生命周期开发者社区

更多推荐