dubbo和微服务注册中心分离

dubbo和微服务分别使用各自的nacos做为注册中心

dubbo-api 作为dubbo父工程
依赖如下:

<!-- Dubbo -->
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo</artifactId>
    <version>2.7.8</version>
</dependency>
<!-- Dubbo Spring Boot Starter -->
<dependency>
    <groupId>org.apache.dubbo</groupId>
    <artifactId>dubbo-spring-boot-starter</artifactId>
    <version>2.7.8</version>
</dependency>
<!-- Netty -->
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-all</artifactId>
    <version>4.1.51.Final</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
<dependency>
    <groupId>org.apache.commons</groupId>
    <artifactId>commons-lang3</artifactId>
    <version>3.12.0</version>
</dependency>
复制代码

dubbo-api.png

在需要使用duboo的项目内引用dubbo-api

如图:

map.png
项目内引微服务注册到nacos的相关依赖,以及实现业务功能的其他依赖。
配置文件:

server:
  port: 18083
spring:
  application:
    name: map
  cloud:
    nacos:
      discovery:
        server-addr: 127.0.0.1:8848
      username: nacos
      password: nacos
management:
  endpoints:
    web:
      exposure:
        include: "*"
dubbo:
  application:
    name: map
  registry:
    address: nacos://127.0.0.1:8849
  consumer:
    check: false
  protocol:
    name: dubbo
    port: -1
复制代码

这样就能实现两个注册中心的分离了,是不是看着很简单,刚开始研究时,还是费不少劲。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享