一、导包
<!--Dubbo-->
<dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-spring-boot-starter</artifactId><version>2.7.8</version>
</dependency>
<!--Zookeeper-->
<dependency><groupId>org.apache.dubbo</groupId><artifactId>dubbo-dependencies-zookeeper</artifactId><version>2.7.8</version><type>pom</type><exclusions><exclusion><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId></exclusion></exclusions>
</dependency>
一、配置文件
(一)服务提供者
dubbo:registry:address: zookeeper://192.168.88.130:2181timeout: 250000scan:base-packages: com.example.dataservice.service.implprovider:timeout: 50000retries: 0 # 失败重试次数
(二)服务消费者
dubbo:registry:address: zookeeper://192.168.88.130:2181timeout: 250000scan:base-packages: com.example.frontconsumer:check: falsetimeout: 50000retries: 0
二、@EnableDubbo
启动Dubbo,做用于SpringBoot启动类上;
三、远程调用
(一)服务提供者的Service
作用于ServiceImpl类上
@DubboService(interfaceClass = PlatBaseInfoService.class, version = "1.0")
(二)服务消费者的Controller
作用于Controller类中的注入Service对象上
@DubboReference(interfaceClass = PlatBaseInfoService.class,version = "1.0")