Search code examples
spring-bootnetflix-eureka

Eureka Client running with name "UNKNOWN" in eureka server UI


I created a Eureka server spring boot application. It is properly loaded. After that I am trying to create a Eureka client.But it is not getting listed in eureka server UI. I am adding my client application details.

My main controller class file is as below,

@SpringBootApplication
@EnableDiscoveryClient
public class ZEurekaClientServiceApplication {

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

And my pom.xml contains the ,

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-eureka</artifactId>
</dependency>

And

<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>

And my application.properties file containing,

eureka.client.serviceUrl.defaultZone=http://localhost:8071/eureka
eureka.client.register-with-eureka=true
eureka.client.fetch-registry=true

When It client is running , the eureka server UI not showing it's name. ONly showing UNKNOWN as application. I am adding its screenshot below.enter image description here

What I need to display the application name instead of "UNKNOWN" in the eureka server UI? Is there is any additional settings to add application name?


Solution

  • You can specify the application name by setting it either in your application.yml or in your application.properties.

    For application.yml:

    spring:
      application:
        name: {YOUR_APPLICATION_NAME}
    

    For application.properties:

    spring.application.name={YOUR_APPLICATION_NAME}