求助,spring cloud多个注册中心,eureka.client.serviceUrl.defaultZone中第二个无法发现服务

一个胖子IT男 一个胖子IT男 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
版本:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.7.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>

<spring-cloud.version>Greenwich.SR2</spring-cloud.version>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>

<!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

注册中心配置文件:
spring.application.name=server
server.port=7001
eureka.instance.hostname=localhost
eureka.client.serviceUrl.defaultZone=http://localhost:7002/eureka/,http://localhost:7001/eureka/

spring.application.name=server
server.port=7002
eureka.instance.hostname=localhost
eureka.client.serviceUrl.defaultZone=http://localhost:7002/eureka/,http://localhost:7001/eureka/

注册中心启动类:
@SpringBootApplication
@EnableEurekaServer
public class SpringEurekaApplication {

public static void main(String[] args) {
SpringApplication.run(SpringEurekaApplication.class, args);
}

}

服务配置文件:
server.port=9001
spring.application.name=product
eureka.client.serviceUrl.defaultZone=http://localhost:7001/eureka/,http://localhost:7002/eureka/

客户端启动类没有加eureka相关注解

此时访问http://localhost:7001,可以看到product,但是http://localhost:7002没有这个服务,两个注册中心可以互相发现,请教各位大牛,这种情况怎么处理? 我把7001端口项目停止后,7002端口是可以发现这个服务的,怎么能让7001和7002同时发现这个服务?
...全文

相关推荐

评论 21
收藏 已收藏
分享
返回顶部
一个胖子IT男
Web 开发 81,107 成员 341,720 内容