spring+zookeeper+dubbo配置

公共文档,provider和consumer分别填写其他内容
<?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:context="http://www.springframework.org/schema/context"
        xmlns:aop="http://www.springframework.org/schema/aop"
        xmlns:tx="http://www.springframework.org/schema/tx"
        xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
        xsi:schemaLocation="
        http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd
        http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
        http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd
        ">
<--这是个公共的文档,provider和consumer分别填写其他内容-->

</beans>
Prodiver服务提供者:
    <!--提供方应用信息,用于计算依赖关系 -->
    <dubbo:application name="prodiver"/>

    <!--用dubbo协议在20880端口暴露服务 -->
    <dubbo:protocol name="dubbo" port="20880"/>

    <!--和本地bean一样实现服务-->
    <bean id="demoServiceImpl" class="demo.server.DemoServiceImpl"/>

    <!--声明需要暴露的服务接口-->
    <dubbo:service interface="demo.api.DemoService" ref="demoServiceImpl" registry="N/A"/>
对应关系
Consumer服务消费者
    <!--消费方应用名,不是匹配条件,不和提供方名字一样-->
    <dubbo:application name="consumer"/>

    <!--和provider.xml的service是一对,provider暴露服务,reference接收-->
    <!--生成远程服务代理,注意,两个xml下的interface的内容都一样,就要求在consumer中创建一份一模一样的ServiceAPI,连路径都要一样-->
    <dubbo:reference interface="demo.api.DemoService"
                     id="demoServiceImpl"
                     url="dubbo://localhost:20880"/>

注意,两个xml下的interface的内容都一样,就要求在consumer中创建一份一模一样的DemoServeice,连路径都要一样
———————————————————————————————————

下面引入zookeeper:

1.在provider的xml文件中,添加:
2.在consumer的xml文件中如下配置
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。