gpt4 book ai didi

spring-boot - 在 Eureka 服务器 UI 中以名称 "UNKNOWN"运行的 Eureka 客户端

转载 作者:行者123 更新时间:2023-12-03 20:17:35 25 4
gpt4 key购买 nike

我创建了一个 Eureka 服务器 Spring Boot 应用程序。它已正确加载。之后我试图创建一个 Eureka 客户端。但它没有在 Eureka 服务器 UI 中列出。我正在添加我的客户端应用程序详细信息。

我的主 Controller 类文件如下,

@SpringBootApplication
@EnableDiscoveryClient
public class ZEurekaClientServiceApplication {

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

我的 pom.xml 包含 ,
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-eureka</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>

我的 application.properties 文件包含,
eureka.client.serviceUrl.defaultZone=http://localhost:8071/eureka
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

当 It 客户端运行时, Eureka 服务器 UI 不显示它的名称。仅将 UNKNOWN 显示为应用程序。我在下面添加它的屏幕截图。 enter image description here

我需要在 Eureka 服务器 UI 中显示应用程序名称而不是“UNKNOWN”吗?是否有任何额外的设置来添加应用程序名称?

最佳答案

您可以通过在 application.yml 中设置它来指定应用程序名称。或在您的 application.properties .

对于 application.yml:

spring:
application:
name: {YOUR_APPLICATION_NAME}

对于 application.properties:
spring.application.name={YOUR_APPLICATION_NAME}

关于spring-boot - 在 Eureka 服务器 UI 中以名称 "UNKNOWN"运行的 Eureka 客户端,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47108260/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com