首页 文章

实例名称在Eureka Dashboard上显示为“unknown”而不是服务名称

提问于
浏览
1

我正在使用Spring启动微服务并使用eureka作为服务器 . 我已在Eureka服务器上注册了我的服务,但在Eureka Dashboard上,服务名称显示为“Unknown”而不是我在application.yml中配置的服务名称 .

下面是yml配置服务器:端口:8761

spring:application:name:eureka-server

eureka:instance:hostname:localhost client:register-with-eureka:false fetch-registry:false service-url:default-zone:http:// $ :$ / eureka /


eureka:client:serviceUrl:defaultZone:http://localhost:8761/eureka/ instance:appname:reporting-engine server:port:0 instance:preferIpAddress:true spring:application:name:reporting-engine


3 回答

  • 0

    尝试创建一个 bootstrap.yml 文件并添加:

    spring.application.name = instanceName
    
  • 0

    在您的applicaton.yml文件中:

    spring:
      application:
        name: yourname
    eureka:
      instance:
         instanceId: ${spring.application.name}
    

    其中“instanceId”对满足您的需求非常重要 .

  • 0

    默认情况下更改属性default-zone . 我与大家分享一下对我有用的东西 .

    application.yml

    Eureka Server

    eureka:
         instance:
           hostname: localhost
         client:  # Not a client, don't register with yourself
           registerWithEureka: false
           fetchRegistry: false
         server:
           enable-self-preservation: false
    
       server:
         port: 8882
    

    Eureka Client

    spring:
         application:
           name: customer
    
       eureka:
        client:
          eureka-connection-idle-timeout-seconds: 60
          serviceUrl:
            defaultZone: http://localhost:8882/eureka/
          healthcheck:
            enabled: true
    

相关问题