注册中心使用:nacos,如果要使用zookeeper,替换pom即可。

pom

  1. <dependency>
  2. <groupId>org.apache.dubbo</groupId>
  3. <artifactId>dubbo</artifactId>
  4. <version>2.7.3</version>
  5. </dependency>
  6. <dependency>
  7. <groupId>org.apache.dubbo</groupId>
  8. <artifactId>dubbo-registry-nacos</artifactId>
  9. <version>2.7.3</version>
  10. </dependency>
  11. <dependency>
  12. <groupId>com.alibaba.nacos</groupId>
  13. <artifactId>nacos-client</artifactId>
  14. <version>1.1.3</version>
  15. </dependency>

provider

  1. dubbo:
  2. scan:
  3. base-packages: com.alvin.service.impl # 可以加逗号分隔
  4. protocol:
  5. name: dubbo
  6. port: -1
  7. registry:
  8. address: nacos://127.0.0.1:8848
  9. provider:
  10. group: test
  11. version: 1.0
  12. retries: 0

consumer

  1. dubbo:
  2. scan:
  3. base-packages: com.alvin.controller
  4. protocol:
  5. name: dubbo
  6. registry:
  7. address: nacos://127.0.0.1:8848
  8. consumer:
  9. group: test
  10. version: 1.0
  11. retries: 0
  12. check: false