java - Spring Boot 管理员无法从 Eureka 获取注册表

标签 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 端点不再是“可访问的”或“Activity 的”。但我在管理服务器或 Eureka 服务器的日志中没有看到任何关于此的错误或警告。
  • 我的其他应用程序在其 pom 中都没有 spring boot admin starter 客户端依赖项,因为我不希望它成为负责在管理控制台注册的部分,我希望它通过 Eureka 动态完成
  • 除管理服务器和 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

最佳答案

升级到 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

关于java - Spring Boot 管理员无法从 Eureka 获取注册表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54208729/

相关文章:

使用 Wacom 数位板进行 java Swing 调试令人头疼

java - 如何编写 Stream.findNth() 代码?

java - Spring @ConditionalOnBean 结合@Component

java - Spring 启动: how to match all routes?

node.js - Spring Cloud Netflix Eureka 找不到 eureka-js 实例

spring-boot - Spring Cloud - 如何为分布式 Spring 应用程序获得重试、负载平衡和断路器的好处

java - TDD:当方法依赖于网络 URL 时如何编写单元测试

java - Spring + Jboss7 @Transactional 不工作

java - 如何使用 springboot findAll() 方法编写 not in 子句

docker - 微服务 使用 Eureka 和 traefik 与 docker compose 进行服务发现