赞
踩
依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>2.4.2</version> </dependency> <!--dubbo框架--> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.6.4</version> </dependency> <!--dubbo的springboot支持--> <dependency> <groupId>com.alibaba.boot</groupId> <artifactId>dubbo-spring-boot-starter</artifactId> <version>0.2.0</version> </dependency> <!--zk依赖--> <!--<dependency> <groupId>org.apache.zookeeper</groupId> <artifactId>zookeeper</artifactId> <version>3.4.13</version> </dependency> <!–zk客户端,注册到zk需要–> <dependency> <groupId>com.github.sgroschupf</groupId> <artifactId>zkclient</artifactId> <version>0.1</version> </dependency>--> <!-- 使用Nacos--> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo-registry-nacos</artifactId> <version>2.6.7</version> </dependency> <!--开启spring对Nacos的支持--> <dependency> <groupId>com.alibaba.spring</groupId> <artifactId>spring-context-support</artifactId> <version>1.0.10</version> </dependency> <dependency> <groupId>io.netty</groupId> <artifactId>netty-all</artifactId> <version>4.1.32.Final</version> </dependency>
配置文件
我们注释掉原来的zk依赖换上最后三个依赖就可以了;
配置只需要变更一个
生产者
server.port=38080
dubbo.application.name = demo-server
# 注册中心地址,去哪找服务
#dubbo.registry.address = zookeeper://127.0.0.1:2181
dubbo.registry.address = nacos://159.23.11.316:8848
dubbo.registry.client = zkclient
dubbo.registry.timeout = 60000
dubbo.consumer.timeout = 60000
#qos
dubbo.application.qos.enable=true
dubbo.application.qos.port=33333
dubbo.application.qos.accept.foreign.ip=false
消费者
server.port=38081
#要把那些服务注册到注册中心
dubbo.scan.basePackages = com.doria.provider
dubbo.application.name = demo-provider
# rpc通讯名称
dubbo.protocol.name = dubbo
# rpc通讯端口
dubbo.protocol.port = -1
# 注册中心地址,把服务注册到哪
#dubbo.registry.address = zookeeper://localhost:2181
dubbo.registry.address = nacos://159.23.11.316:8848
dubbo.registry.client = zkclient
dubbo.registry.timeout = 10000
zookeeper://127.0.0.1:2181
变更为nacos://159.23.11.316:8848
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。