如何利用SpringCloud - Dubbo进行远程调用?

俞飞鸣
2023-12-01


一、引入依赖

   <!-- Dubbo Spring Cloud Starter -->
        <dependency>
            <groupId>com.alibaba.cloud</groupId>
            <artifactId>spring-cloud-starter-dubbo</artifactId>
        </dependency>

提示:这是Spring-cloud 集成的dubbo依赖

二、properties文件进行配置

dubbo.scan.base-packages=cn.com.bmsmart.inspenctplan.service.inspectplaninterface
dubbo.registry.address=spring-cloud://10.0.43.xxx:8848
#dubbo.registry.address=spring-cloud://10.0.43.xx:8848
dubbo.protocol.name=dubbo
dubbo.protocol.port=20889
dubbo.cloud.subscribed-services=cm,prod,inv,ocm

三、注入bean开启调用

  @DubboReference(check = false, timeout = 30000)
  private OcmInternalInterfaceService ocmInternalInterfaceService;
 类似资料: