SpringBoot+zk+dubbo个人分析

1.先下载zookeeper压缩包,解压后在conf文件中新增zoo.cfg

  单机模式:

# The number of milliseconds of each tick  心跳间隔 毫秒每次
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting anacknowledgement
syncLimit=5
# the directory where the snapshot isstored.  //镜像数据位置
dataDir=F:\wds\zookeeper-3.4.8\\data\\zookeeper
#日志位置
dataLogDir=F:\wds\zookeeper-3.4.8\\logs\\zookeeper
# the port at which the clients willconnect  客户端连接的端口
clientPort=2181
server.1=127.0.0.1:2888:3888.

2.新建2个工程,SpringProvider(生产提供者)、SpringConsumer(消费者)

SpringProvider(生产提供者)中暴露服务接口,例如:

## Dubbo 服务提供者配置
spring.dubbo.application.name=provider
spring.dubbo.registry.address=zookeeper://127.0.0.1:2181
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20880
spring.dubbo.scan=com.springboot.demoDu.service

但是如果是用Spring的话,则在xml文件中加

<!-- 声明需要暴露的服务接口 -->
 

<dubbo:service interface="egg.operate.service.api.platformData.IBrandService" ref="brandService"></dubbo:service>

在消费者中则写

<dubbo:reference interface="egg.operate.service.api.platformData.IBrandService" id="brandService"></dubbo:reference>

 

在SpringConsumer(消费者)中用注解的形式调用服务接口

@Reference
    UserService userService;

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值