dubbo配置

dubbo

  • 环境
需要注册中心 : zookeeper 或其他
  • 依赖 (消费者和提供者都需要)
        <!--dubbo包-->
        <dependency>
            <groupId>com.alibaba</groupId>
            <artifactId>dubbo</artifactId>
            <version>2.5.8</version>
        </dependency>
        <!-- zookeeper连接包-->
        <dependency>
            <groupId>com.github.sgroschupf</groupId>
            <artifactId>zkclient</artifactId>
            <version>0.1</version>
        </dependency>

        <dependency>
            <groupId>org.apache.zookeeper</groupId>
            <artifactId>zookeeper</artifactId>
            <version>3.4.9</version>
        </dependency>
  • 配置文件
    • 提供者
<?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管理页面比较清晰是哪个应用暴露出来的 -->  
  <dubbo:application name="ucenter"></dubbo:application>  
  <!--使用zookeeper注册中心暴露服务地址 -->  

   <dubbo:registry address="zookeeper://10.10.100.205:2181" timeout="500000"/>

  <!--要暴露的服务接口 -->  
  <dubbo:service interface="cn.com.api.service.CityOperatorsManageInfoService" ref="cityOperatorsManageInfoServiceImpl"/>  

</beans>  
  • 配置文件
    • 消费者
<?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="goods_repo" />  

    <!-- 使用zookeeper注册中心暴露服务地址 -->  
    <!-- <dubbo:registry address="multicast://224.5.6.7:1234" /> -->  
    <dubbo:registry address="zookeeper://10.10.100.205:2181"/>  

  <dubbo:protocol accesslog="/data/logs/access.log"  name="ucenter"   host="192.168.30.1" port="20880" />
    <!-- 生成远程服务代理,可以像使用本地bean一样使用demoService -->  
    <dubbo:reference id="cityOperatorsManageInfoService"  
        interface=" com.smedia.service.CityOperatorsManageInfoService"/>  

</beans>  

说明

 CityOperatorsManageInfoService 为公用接口,需要打入jar文件中,供提供者服务器和消费者服务器调用
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值