如何在不使用application.properties文件的情况下曝光Spring启动执行器端点?
如果我无法访问application.properties
文件,则如何在Spring Boot 2.5.8中启用和曝光执行器端点?
使用application.properties
文件,只需配置
Management.endpoints.web.exposus.include =*
,
但是如果我无法访问application, .properties
,我该如何用代码进行?
How can I enable and exposure actuator endpoints in Spring boot 2.5.8 application if I don't have access to application.properties
file?
It's easy to do with application.properties
file, just configuring
management.endpoints.web.exposure.include=*
But if I don't have access to application.properties
, how can I do it in code?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将属性添加为环境变量。只需要切换套管和
。
<代码> _management_endpoints_web_exposure_include =*
You can add the properties as environment variables. Just need to switch casing and
.
to_
MANAGEMENT_ENDPOINTS_WEB_EXPOSURE_INCLUDE=*
您可以使用命令行进行相同的操作。
You can use command line to do the same.
最后,我找到了2个解决方案。
在运行应用程序之前使用springApplication.setDefaultProperties()方法:
第二种方法需要访问属性文件。
要使用propertiesConfiguration打开属性文件(此类可以:从文件中读取属性并将新属性/值写入文件)。
检查属性是否已经存在
如果不存在 - 添加。
在应用程序运行之前,所有这些操作还需要以主方法执行。
Finally, I found 2 solutions.
To use SpringApplication.setDefaultProperties() method before run application:
Second approach requires access to properties file.
To open properties file with PropertiesConfiguration (this class can both: read properties from file and write new properties/values to file).
Checked if property already exist
If not exist - add it.
All this actions also need to perform in main method before application run.