2017-11-04 77 views
0

我創建了一個尤里卡服務器彈簧引導應用程序。它被正確加載。之後,我正在嘗試創建一個Eureka客戶端,但它並未在尤里卡服務器UI中列出。我正在添加我的客戶端應用程序細節尤里卡客戶端在尤里卡服務器用戶界面中使用名稱「UNKNOWN」運行

我的主控制器類文件如下,

@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 

當客戶端運行時,尤里卡服務器UI未顯示其名稱。僅顯示UNKNOWN作爲應用程序。我在下面添加它的截圖。 enter image description here

我需要在尤里卡服務器UI中顯示應用程序名稱而不是「UNKNOWN」嗎?是否有其他設置可以添加應用程序名稱?任何人都可以幫我澄清這個問題嗎?

回答

1

您可以通過在application.ymlapplication.properties中指定應用程序名稱。

對於application.yml:

spring: 
    application: 
    name: {YUOR_APPLICATION_NAME} 

對於applciation.yml:

spring.application.name={YUOR_APPLICATION_NAME} 
+0

是。我知道了,它正在工作。感謝您的答覆。 – Jacob

相關問題