炫意html5
最早CSS3和HTML5移动技术网站之一

求一个dubbo3.0整合nacos 的demo

求一个dubbo3.0整合nacos 的demo 我整合的一直报错跑不起来

回答

弄了半天不是pom写的不对 是端口问题 下图是官方说明

1.增加2个端口 根据主端口偏移生成
2.如果经过nginx需要需要配置成TCP转发

我的问题算是端口没有开放,连接nacos服务 用的8848端口,其实服务是起在 8818 8828 8838的 通过nginx 8848转发到四个端口上的 所以我连接8848的话 偏移1000的 9848端口是没有的 等同于端口没开放

最后不经过nginx 直接连实际服务端口 连接问题解决

然后出现了新的问题
Caused by: com.alibaba.nacos.api.exception.NacosException: Nacos cluster is running with 1.X mode, can't accept gRPC request temporarily. Please check the server status or close Double write to force open 2.0 mode. Detail https://nacos.io/en-us/docs/2.0.0-upgrading.html

这个问题也很明显里面写了
Please check the server status or close Double write to force open 2.0 mode
翻译过来就是
检查服务状态或者关闭双写 切换到2.0模式
解决
关闭双写命令: curl -X PUT 'localhost:8848/nacos/v1/ns/operator/switches?entry=doubleWriteEnabled&value=false'

以下是完整的pom

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
	<modelVersion>4.0.0</modelVersion>
	<parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.5.4</version>
		<relativePath/> <!-- lookup parent from repository -->
	</parent>
	<groupId>com.baihe.service</groupId>
	<artifactId>baihe-dubbo-user</artifactId>
	<version>0.0.1-SNAPSHOT</version>
	<name>baihe-dubbo-user</name>
	<description>Demo project for Spring Boot</description>
	<properties>
		<java.version>1.8</java.version>
		<apache-dubbo.version>3.0.4</apache-dubbo.version>
		<spring-cloud-alibaba.version>2.2.6.RELEASE</spring-cloud-alibaba.version>
	</properties>
	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
		</dependency>


		<!-- Dubbo dependency -->
		<dependency>
			<groupId>org.baihe</groupId>
			<artifactId>dubbo-api</artifactId>
			<version>1.0</version>
		</dependency>

		<!-- alibaba-cloud依赖 -->
		<dependency>
			<groupId>com.alibaba.cloud</groupId>
			<artifactId>spring-cloud-alibaba-dependencies</artifactId>
			<version>${spring-cloud-alibaba.version}</version>
			<type>pom</type>
			<scope>import</scope>
		</dependency>

		<!-- dubbo依赖 -->
		<dependency>
			<groupId>org.apache.dubbo</groupId>
			<artifactId>dubbo-spring-boot-starter</artifactId>
			<version>${apache-dubbo.version}</version>
		</dependency>


		<!-- dubbo-nacos注册 -->
		<dependency>
			<groupId>org.apache.dubbo</groupId>
			<artifactId>dubbo-registry-nacos</artifactId>
			<version>${apache-dubbo.version}</version>
			<exclusions>
				<exclusion>
					<groupId>org.apache.dubbo</groupId>
					<artifactId>dubbo-common</artifactId>
				</exclusion>
				<exclusion>
					<groupId>org.apache.dubbo</groupId>
					<artifactId>dubbo-remoting-api</artifactId>
				</exclusion>
			</exclusions>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>
</project>

炫意HTML5 » 求一个dubbo3.0整合nacos 的demo

Java基础教程Android基础教程