@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×tamp=1546081206661 to registry registry://zk1.test.yiyaowang.com:2181/com.alibaba.dubbo.registry.RegistryService?application=demo-provider&dubbo=2.6.2&pid=85235®istry=zookeeper×tamp=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
请注意看报错信息 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
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。
阿里云拥有国内全面的云原生产品技术以及大规模的云原生应用实践,通过全面容器化、核心技术互联网化、应用 Serverless 化三大范式,助力制造业企业高效上云,实现系统稳定、应用敏捷智能。拥抱云原生,让创新无处不在。