2017-11-04 91 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

相关问题