1.父工程,和子工程pom引入依赖
我这用的是springboot 2.0.4版本
<!--dubbo-->
<dependency>
<groupId>com.alibaba.boot</groupId>
<artifactId>dubbo-spring-boot-starter</artifactId>
<version>0.2.0</version>
</dependency>
<!--zookeeper-->
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.2</version>
</dependency>
2.服务提供者配置添加
dubbo:
application:
id: user-server
name: user-server
protocol:
id: dubbo
name: dubbo
port: 20880
registry:
address: zookeeper://127.0.0.1:2181
id: my-registry
scan:
basePackages: com.shop.user.service.impl
spring:
application:
name: user-server
3.服务消费者配置添加
dubbo:
application:
id: user-web
name: user-web
protocol:
id: dubbo
name: dubbo
port: 20880
registry:
address: zookeeper://127.0.0.1:2181
id: my-registry
4.服务提供者添加@service注解,注意引的包是dubbo的
5.服务消费者使用@Reference注解注入服务提供者,包也是dubbo里的
6.启动zookeeper,开始测试
坑很多,自己慢慢填