我有一个 Java Spring Boot 应用程序,目前正在 http://localhost:8080 上运行.我将容器化这个应用程序以部署在 Kubernetes 中。为此,我启用了 actuator health
端点通过将以下内容添加到 pom.xml
文件。
<!-- Spring boot actuator to expose metrics endpoint -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
现在,应用程序 Health Endpoint 在 http://localhost:8080/actuator/health 上成功运行端点。我想改变的PORT健康端点 URL 为 8081 . (这是为了保证我可以把8080端口暴露给公众,8081端口只暴露给负载均衡器。这个是个人喜好)
如何更改 的端口健康端点 以便健康端点 URL 变为 http://localhost:8081/actuator/health ,并且应用程序在 http://localhost:8080/ 上运行.
最佳答案
默认情况下,可以使用配置的默认 http 端口(通常是 8080)访问执行器。
Actuator 有许多您可以配置的配置属性,属于 management.
字首。您可以专门设置management.port
在 application.properties
在自定义端口上提供执行器端点:
在 application.properties
, 放:
management.port=8081
有关更多详细信息,请查看 Spring Boot - Production Ready Monitoring 的第 48.2 节文档。
关于Java Spring Boot - 将 Actuator Health Endpoint 的端口更改为自定义端口,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61685392/