spring-boot - 如何启用在自定义启动器/库中设置的执行器端点?
问题描述
我有自定义启动器应用程序(库),它具有执行器和普罗米修斯依赖项
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>io.micrometer</groupId>
<artifactId>micrometer-registry-prometheus</artifactId>
<version>1.5.2</version>
</dependency>
在 application.properties
management.endpoints.web.exposure.include=health, info, metrics, prometheus
我在我的其他应用程序中使用这个启动器,我还想从启动器传递端点的这个展示。Actuator 和 Prometheus 依赖项在应用程序中有效,但在 starter 中不显示选定的端点。Ofc 我也可以management.endpoints.web.exposure.include=health, info, metrics, prometheus
在我的应用程序中添加行,但是对于使用此启动器的多个应用程序,我想一劳永逸地传递它,并仅在需要时在启动器中更改端点。
你知道如何在我的应用程序中公开那些在启动器中设置的端点吗?
Spring Boot v2.3.2 / Maven 3.6.3
解决方案
当您启动应用程序时,您可以将其作为命令行参数或作为 ENV vars 传递给您的 jar。
这样,您可以在需要时将其传递给所需的应用程序,而无需更新 application.properties。
它还将防止在不需要时暴露执行器端点,因为执行器端点会显示有关应用程序的敏感信息。
例如。java -Dmanagement.endpoints.web.exposure.include=health, info, metrics, prometheus -jar myapp.jar
推荐阅读
- javascript - 如何使音频按我想要的方式工作?
- laravel - 如何使用 laravel、VUE 和 NUXT.js 通过 API 下载 CSV 文件?
- azure-devops - Azure Artifacts 仅下载在构建服务器上部署所需的特定文件
- typescript - 类型“{}”.ts(2339) 上不存在属性“我”
- r - 当我输出ggplot图时,函数的结果不同,为什么?
- c++ - Windows 服务不创建故障转储
- python - Pandas - fillna 与特定类别的平均值
- c++ - 在编写新代码时,作为错误不会妨碍的推荐的警告集是什么?
- javascript - 为什么我的带有 viewBox 和十六进制编码颜色的 SVG 图标在用作 javascript Image() 的“.src”时无法呈现
- node.js - 在 NodeJS 中使用 Tabulator 和 ExpressJS