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