Spring Boot Admin无法从Eureka获取注册表

时间:2019-01-16 00:22:13

标签: java spring-boot netflix-eureka spring-boot-admin

我使用的是Spring Boot 2.0.X,并且想要使用一个自动检测在Eureka注册的其他服务的管理服务器。我已按照this guide的字母进行操作,但是管理控制台中未显示任何应用程序。所有应用程序都已成功向Eureka注册。

管理服务器配置:

server:
  port: 8762

spring:
  application:
    name: admin-server
  boot:
    admin:
      discovery:
        ignored-services: admin-server
#The admin server will automatically pick up all services at eureka and register them to itself.
eureka:
  instance:
    leaseRenewalIntervalInSeconds: 10
    health-check-url-path: /actuator/health
    metadata-map:
      startup: ${random.int}    #needed to trigger info and endpoint update after restart
  client:
    registryFetchIntervalSeconds: 5
    registerWithEureka: true #default true
    fetchRegistry: true #default true
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

management:
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

Eureka服务器配置:

server:
  port: 8761
spring:
  application:
    name: discovery-server
eureka:
  instance:
    hostname: localhost
  client:
    registerWithEureka: false
    fetchRegistry: false
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/

一些想法:

  • 我们从Spring Boot 1.5.x迁移到2.0.x,是否存在问题 安全?我们没有在任何地方使用spring-security,但我读了一些 默认情况下,http端点不再是“可达”或“活动”的。但我在管理服务器或eureka服务器的logf中没有看到有关此的错误或警告。
  • 我的其他应用程序都没有在pom中具有spring boot admin starter client依赖项,因为我不希望THAT成为负责向管理控制台注册的部分,所以我希望通过Eureka动态完成它。 / li>
  • 除管理服务器和eureka服务器以外的所有应用程序均使用 配置服务器以获取其配置。这会导致 有问题吗?

所有其他应用程序从配置服务器获取的application.yml包含以下内容:

eureka:
  client:
    serviceUrl:
      defaultZone: http://localhost:8761/eureka/
spring:
  boot:
    admin:
      url: http://localhost:8762
management: #exposing all endpoints is not safe for production, especially not if spring security gets involved
  endpoints:
    web:
      exposure:
        include: "*"
  endpoint:
    health:
      show-details: ALWAYS

1 个答案:

答案 0 :(得分:1)

升级到SBA2时,我遇到了同样的问题。

spring-boot,spring-cloud和SBA的版本应该匹配。我用过:

spring-boot:  2.0.7.RELEASE
spring-cloud: Finchley.SR2
SBA:          2.0.4

在我的情况下,诀窍是使用spring-boot-admin-starter-server作为依赖项而不是简单的依赖项(spring-boot-admin-server,spring-boot-admin-server-ui,spring-boot-admin -server-cloud),如下所示: https://github.com/codecentric/spring-boot-admin/issues/776