首页 > 解决方案 > 在 Spring boot 1.5.2 版本中,Actuator 端点未通过 HTTP 暴露在与应用程序运行相同的端口中

问题描述

我正在使用 springboot 版本 1.5.2.RELEASE 并且我尝试在我的应用程序中实现 spring boot 执行器。我正在端口 8081 中运行我的应用程序。我只想公开两个端点,即健康和信息。当我尝试访问与我的应用程序相同的端口 8081 中的端点时,它没有给出结果并在 Postman 中显示 404 not found 状态。我可以通过http://localhost:8089/admin/info访问端口 8089 中的健康端点。我在端口 8081 中无法实现同样的事情。我已经搜索了答案,但找不到 Spring Boot 版本 1.5.2 的正确答案。我的 application.yml 文件如下所示:

management:
  context-path : /admin
  endpoints:
    web:
      exposure:
        include: health,info
    jmx:
      exposure:
        exclude: '*'
  security:
    enabled: true
  port: 8081

标签: spring-bootspring-boot-actuator

解决方案


如果您management.port设置为8089,那么您将只能在该端口访问管理 API。您将无法在应用程序端口访问它们8081

如果您想访问应用程序端口的管理 API,请不要设置该managment.port值。它默认使用与应用程序端口相同的端口。


推荐阅读