Spring Boot Actuator / health endpoint不显示数据库或文件系统信息

我无法获取要显示在/ health端点上的数据库信息或文件系统信息。 我只能得到:

{ "status": "UP" } 

有关我的设置和配置的详细信息: – Spring Boot 1.3.3 – 在JBoss EAP 6.4上运行WAR – Datasource是一个JNDI资源。 – Oracle是数据库

 spring: datasource: # Must match the datasource name in JBoss standalone.xml jndi-name: java:jboss/beautiful-ds driver-class-name: oracle.jdbc.driver.OracleDriver jpa: properties: # escapes reserved words used as column names (if any) globally_quoted_identifiers: true show-sql: true hibernate: naming_strategy: org.hibernate.cfg.EJB3NamingStrategy server: servlet-path: /* management: health: diskspace: enabled: true db: enabled: true endpoints.health.sensitive: false 

我在/ configprops上找到的一件事就是这个,我不确定它是否相关:

  "spring.datasource.CONFIGURATION_PROPERTIES": { "prefix": "spring.datasource", "properties": { "error": "Cannot serialize 'spring.datasource'" } 

我曾尝试添加“driver-class-name:oracle.jdbc.driver.OracleDriver”,认为它可能需要更多细节,但这并没有改变这种情况。

是的,是什么给出的? 我做了一个vanilla示例项目,至少显示了文件系统的东西,所以不知道为什么要么不想在我的“真实”应用程序中显示。 告诉我你伟大而明智的答案! 🙂

如果您使用弹簧安全性,则默认情况下会为执行器端点启用安全性,在yml文件中禁用它 –

 management: security: enabled: false 

默认情况下,Spring将以下属性设置为never 。 为了能够查看完整的运行状况详细信息,请将以下属性添加到application.properties

 management.endpoint.health.show-details=always 

spring-boot文档:

45.6 HealthIndicators的安全性

HealthIndicators返回的信息通常在某种程度上是敏感的。 例如,您可能不希望向全世界发布数据库服务器的详细信息。 因此,默认情况下,仅通过未经身份validation的HTTP连接公开运行状况。 如果您希望始终公开完整的健康信息,则可以将endpoints.health.sensitive设置为false。 还会缓存健康响应以防止“拒绝服务”攻击。 如果要将默认缓存时间更改为1000毫秒,请使用endpoints.health.time-to-live属性。

确保设置了以下属性。

 endpoints.health.sensitive=true # Mark if the endpoint exposes sensitive information. management.health.db.enabled=true # Enable database health check. management.health.defaults.enabled=true # Enable default health indicators. management.health.diskspace.enabled=true # Enable disk space health check. 

IIUC,总健康状况显示在/ health,至少(IIUC)springboot2。 这意味着,即使您配置的所有内容都恰到好处,也只会显示一行。

更新:如果这不是您所需要的,您必须特别要求查看详细信息。 检查以下设置:

 management.endpoint.health.show-details=when-authorized management.endpoint.health.roles=ADMIN 

您在配置文件中混合了YAML和Properties语法。 用以下内容替换最后一行,它应该工作:

 endpoints: health: sensitive: false