Spring Boot spring.datasource.CONFIGURATION_PROPERTIES无法序列化

时间:2016-04-06 18:19:45

标签: java spring jboss spring-boot spring-boot-actuator

我已经配置了一个可以在我的代码中运行的数据源,但是我无法在Actuator / metrics端点上报告指标。

我的设置如下:

  • Spring Boot 1.3.3
  • 在JBoss中定义的JBoss EAP 6.4 JNDI数据源
  • 在Spring Boot
  • 的application.properties中配置的JNDI数据源
  • Oracle数据库

它确实出现在/荒地上。 我在/ configprops端点上注意到以下内容,我猜是问题...虽然我不知道如何处理它:

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

就像我说的那样,快乐" on / 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

1 个答案:

答案 0 :(得分:2)

Spring Boot仅为以下类型的DataSource提供开箱即用的指标:

  • com.zaxxer.hikari.HikariDataSource
  • org.apache.commons.dbcp.BasicDataSource
  • org.apache.commons.dbcp2.BasicDataSource
  • org.apache.tomcat.jdbc.pool.DataSource

要获取JBoss数据源的指标,您需要提供一个DataSourcePoolMetadataProvider bean,它返回一个特定于JBoss DataSourcePoolMetaData实现的DataSource实现。