目录
[TOC]
该文档是使用springboot
+dubbo
+nacos
官方文档
https://cn.dubbo.apache.org/zh-cn/overview/mannual/java-sdk/reference-manual/registry/nacos/
https://nacos.io/docs/latest/ecology/use-nacos-with-dubbo/
依赖
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
| <dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo</artifactId> <version>3.2.11</version> </dependency>
<dependency> <groupId>org.apache.dubbo</groupId> <artifactId>dubbo-registry-nacos</artifactId> <version>3.2.11</version> </dependency>
<dependency> <groupId>com.alibaba.spring</groupId> <artifactId>spring-context-support</artifactId> <version>1.0.11</version> </dependency>
|
提供者
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| dubbo: provider: timeout: 5000 application: name: redisson-study registry: address: nacos://127.0.0.1:8848 parameters: namespace: 12387225-0718-4b40-8259-8526a60311ba protocol: name: dubbo
|
启动类
1 2 3 4 5 6 7 8 9
| @EnableDubbo @SpringBootApplication public class DubboApplication {
public static void main(String[] args) { SpringApplication.run(DubboApplication.class, args); }
}
|
消费者
配置文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| dubbo: consumer: timeout: 5000 application: name: redisson-study registry: address: nacos://127.0.0.1:8848 parameters: namespace: 12387225-0718-4b40-8259-8526a60311ba protocol: name: dubbo
|
Docker部署
dubbo主机配置:https://cn.dubbo.apache.org/zh-cn/docs/advanced/set-host/
1 2 3 4 5 6 7 8 9
| version: "3.8"
services: springboot-project: environment: DUBBO_IP_TO_REGISTRY: 公网ip/域名 DUBBO_PORT_TO_REGISTRY: 注册端口
|