我配置了一个可以在我的代码中工作的数据源,但我无法让它报告 Actuator/metrics 端点上的指标。
我的设置如下:
- Spring Boot 1.3.3
- JBoss EAP 6.4 JNDI 数据源在 JBoss 中定义
- 在 application.properties 中为 Spring Boot 配置 JNDI 数据源
- Oracle 数据库
它确实出现在/heath 上。 我在/configprops 端点上注意到以下内容,我猜这就是问题所在......尽管我不确定该怎么办:
"spring.datasource.CONFIGURATION_PROPERTIES": {
"prefix": "spring.datasource",
"properties": {
"error": "Cannot serialize 'spring.datasource'"
}
},
就像我说的,/health 上很“快乐”:
{
"status": "UP",
"customHealthCheck": {
"status": "UP"
},
"jms": {
"status": "UP",
"provider": "HornetQ"
},
"diskSpace": {
"status": "UP",
"total": 499055067136,
"free": 285583982592,
"threshold": 10485760
},
"db": {
"status": "UP",
"database": "Oracle",
"hello": "Hello"
}
}
这是我的 application.properties,如果有任何帮助的话。
server.servlet-path=/*
spring.datasource.driver-class-name=oracle.jdbc.OracleDriver
spring.datasource.jndi-name=java:jboss/yourfriendthedatabase-ds
spring.datasource.validation-query=SELECT 1 FROM DUAL
# escapes reserved words used as column names (if any)
spring.jpa.properties.globally_quoted_identifiers=true
spring.jpa.properties.show-sql=true
spring.jpa.properties.hibernate.naming_strategy=org.hibernate.cfg.EJB3NamingStrategy
management.security.enabled=false
management.health.db.enabled=true
management.health.diskspace.enabled=true
endpoints.health.enabled=true
endpoints.health.sensitive=false
endpoints.metrics.sensitive=false
最佳答案
Spring Boot 仅为以下类型的数据源
提供开箱即用的指标:
com.zaxxer.hikari.HikariDataSource
org.apache.commons.dbcp.BasicDataSource
org.apache.commons.dbcp2.BasicDataSource
org.apache.tomcat.jdbc.pool.DataSource
要获取 JBoss DataSource 的指标,您需要提供一个 DataSourcePoolMetadataProvider
bean,它返回特定于 JBoss DataSource
实现的 DataSourcePoolMetaData
实现.
关于java - Spring Boot spring.datasource.CONFIGURATION_PROPERTIES 无法序列化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36459269/