开发者社区 > 云原生 > 正文

Dubbo的demo.的问题

@configuration @DubboComponentScan("com.alibaba.csp.sentinel.demo.dubbo.demo1") public class ProviderConfiguration {

@Bean public ApplicationConfig applicationConfig() { ApplicationConfig applicationConfig = new ApplicationConfig(); applicationConfig.setName("demo-provider"); return applicationConfig; }

@Bean public RegistryConfig registryConfig() { RegistryConfig registryConfig = new RegistryConfig(); registryConfig.setAddress("zookeeper://zk1.test.yiyaowang.com:2181"); return registryConfig; }

@Bean public ProtocolConfig protocolConfig() { ProtocolConfig protocolConfig = new ProtocolConfig(); protocolConfig.setName("dubbo"); protocolConfig.setPort(25758); return protocolConfig; }

} 我就改了provider 和consumer的注册地址啊.......

可是报了这个错.. 十二月 29, 2018 7:00:06 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info 信息: [DUBBO] Register dubbo service com.alibaba.csp.sentinel.demo.dubbo.FooService url dubbo://10.6.24.111:25758/com.alibaba.csp.sentinel.demo.dubbo.FooService?anyhost=true&application=demo-provider&bind.ip=10.6.24.111&bind.port=25758&dubbo=2.6.2&generic=false&interface=com.alibaba.csp.sentinel.demo.dubbo.FooService&methods=doAnother,sayHello&pid=85235&side=provider&timestamp=1546081206661 to registry registry://zk1.test.yiyaowang.com:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&dubbo=2.6.2&pid=85235&registry=zookeeper&timestamp=1546081206653, dubbo version: 2.6.2, current host: 10.6.24.111 十二月 29, 2018 7:00:06 下午 com.alibaba.dubbo.common.logger.jcl.JclLogger info 信息: [DUBBO] Start NettyServer bind /0.0.0.0:25758, export /10.6.24.111:25758, dubbo version: 2.6.2, current host: 10.6.24.111 Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/curator/RetryPolicy at com.alibaba.dubbo.remoting.zookeeper.curator.CuratorZookeeperTransporter.connect(CuratorZookeeperTransporter.java:27) at com.alibaba.dubbo.remoting.zookeeper.ZookeeperTransporter$Adaptive.connect(ZookeeperTransporter$Adaptive.java) at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistry.(ZookeeperRegistry.java:69) at com.alibaba.dubbo.registry.zookeeper.ZookeeperRegistryFactory.createRegistry(ZookeeperRegistryFactory.java:38) at com.alibaba.dubbo.registry.support.AbstractRegistryFactory.getRegistry(AbstractRegistryFactory.java:96) at com.alibaba.dubbo.registry.RegistryFactory$Adaptive.getRegistry(RegistryFactory$Adaptive.java) at com.alibaba.dubbo.registry.integration.RegistryProtocol.getRegistry(RegistryProtocol.java:202) at com.alibaba.dubbo.registry.integration.RegistryProtocol.export(RegistryProtocol.java:136) at com.alibaba.dubbo.qos.protocol.QosProtocolWrapper.export(QosProtocolWrapper.java:54) at com.alibaba.dubbo.rpc.protocol.ProtocolListenerWrapper.export(ProtocolListenerWrapper.java:55) at com.alibaba.dubbo.rpc.protocol.ProtocolFilterWrapper.export(ProtocolFilterWrapper.java:98) at com.alibaba.dubbo.rpc.Protocol$Adaptive.export(Protocol$Adaptive.java) at com.alibaba.dubbo.config.ServiceConfig.doExportUrlsFor1Protocol(ServiceConfig.java:506) at com.alibaba.dubbo.config.ServiceConfig.doExportUrls(ServiceConfig.java:358) at com.alibaba.dubbo.config.ServiceConfig.doExport(ServiceConfig.java:317) at com.alibaba.dubbo.config.ServiceConfig.export(ServiceConfig.java:216) at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:123) at com.alibaba.dubbo.config.spring.ServiceBean.onApplicationEvent(ServiceBean.java:49) at org.springframework.context.event.SimpleApplicationEventMulticaster.doInvokeListener(SimpleApplicationEventMulticaster.java:172) at org.springframework.context.event.SimpleApplicationEventMulticaster.invokeListener(SimpleApplicationEventMulticaster.java:165) at org.springframework.context.event.SimpleApplicationEventMulticaster.multicastEvent(SimpleApplicationEventMulticaster.java:139) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:400) at org.springframework.context.support.AbstractApplicationContext.publishEvent(AbstractApplicationContext.java:354) at org.springframework.context.support.AbstractApplicationContext.finishRefresh(AbstractApplicationContext.java:888) at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:553) at com.alibaba.csp.sentinel.demo.dubbo.demo1.FooProviderBootstrap.main(FooProviderBootstrap.java:50) Caused by: java.lang.ClassNotFoundException: org.apache.curator.RetryPolicy at java.net.URLClassLoader.findClass(URLClassLoader.java:381) at java.lang.ClassLoader.loadClass(ClassLoader.java:424) at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335) at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ... 26 more

原提问者GitHub用户huihui1112

展开
收起
码字王 2023-05-19 19:15:23 131 0
1 条回答
写回答
取消 提交回答
  • 请注意看报错信息 Caused by: java.lang.ClassNotFoundException: org.apache.curator.RetryPolicy 提示zookeeper的客户端找不到。

    registryConfig.setAddress("zookeeper://zk1.test.yiyaowang.com:2181") 这句代码指定了zookeeper作为注册中心。

    demo里用的multicast注册中心,不需要zookeeper依赖,所以没有引; 可以参考sentinel-datasource-zookeeper模块的配置文件,引入zookeeper和zookeeper客户端的依赖。

    org.apache.zookeeper zookeeper 3.4.13

    org.apache.curator curator-recipes 4.0.1 org.apache.zookeeper zookeeper

    参考: http://dubbo.apache.org/zh-cn/docs/user/references/registry/multicast.html http://dubbo.apache.org/zh-cn/docs/user/references/registry/zookeeper.html

    原回答者GitHub用户cdfive

    2023-05-19 22:46:00
    赞同 展开评论 打赏
问答标签:
问答地址:

阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。

相关电子书

更多
Dubbo开源现状与2.7规划 立即下载
Dubbo分布式服务治理实战 立即下载
《Dubbo 3.0 前瞻》 立即下载