Java — springboot 配置 dubbo

  • Post author:
  • Post category:java


1、配置依赖

<dependencies>
  <dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>2.7.5</version>
  </dependency>
  <dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-recipes</artifactId>
    <version>4.2.0</version>
  </dependency>
  <dependency>
    <groupId>org.apache.curator</groupId>
    <artifactId>curator-framework</artifactId>
    <version>4.2.0</version>
  </dependency>
</dependencies>

2、application.properties 注册地址

dubbo.application.name=dubbo-provider
dubbo.registry.address=127.0.0.1:2181
dubbo.registry.protocol=zookeeper

# 仅调用时检测服务
dubbo.consumer.check=false

# 仅生产者配置
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880

3、启动类配置

@EnableDubbo 注解

4、业务层配置

//生产者
@org.apache.dubbo.config.annotation.Service 注解

//消费者
@Reference 注解



版权声明:本文为sky_eyeland原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。