710661809 发表于 2015-11-21 15:16:43

第六章 dubbo之 zookeeper + provider + consumer

  相关代码跟第四章的一样,就是provider的xml配置文件不同:
  <?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>
<beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; xmlns:dubbo=&quot;http://code.alibabatech.com/schema/dubbo&quot;
xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd
&quot;>
<!-- 提供方应用信息,用于计算依赖关系 -->
<dubbo:application name=&quot;hello-world-app&quot; />
<!-- 使用zookeeper广播注册中心暴露服务地址 -->
<dubbo:registry address=&quot;zookeeper://127.0.0.1:2181&quot; />
<!-- 使用dubbo协议在20880端口暴露服务 -->
<dubbo:protocol name=&quot;dubbo&quot; port=&quot;20880&quot;></dubbo:protocol>
<!-- 和本地服务一样实现远程服务 -->
<bean id=&quot;helloWorld&quot; class=&quot;cn.lichunan.dubbo.provider.impl.HelloWorldImpl&quot;></bean>
<!-- 保留远程服务配置 -->
<dubbo:service interface=&quot;cn.lichunan.dubbo.provider.HelloWorld&quot; ref=&quot;helloWorld&quot;></dubbo:service>
</beans>    当然这一章中还要安装zookeeper做为注册中心。




  

页: [1]
查看完整版本: 第六章 dubbo之 zookeeper + provider + consumer