【问题标题】:Spring Boot spring.datasource.CONFIGURATION_PROPERTIES Cannot SerializeSpring Boot spring.datasource.CONFIGURATION_PROPERTIES 无法序列化
【发布时间】:2016-04-06 18:19:45
【问题描述】:

我配置了一个在我的代码中工作的数据源,但我无法让它报告 Actuator /metrics 端点上的指标。

我的设置如下:

  • Spring Boot 1.3.3
  • 在 JBoss 中定义的 JBoss EAP 6.4 JNDI 数据源
  • 在 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

【问题讨论】:

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


    【解决方案1】:

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

    • 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 实现。

    【讨论】:

      猜你喜欢
      • 2017-05-24
      • 2018-10-29
      • 1970-01-01
      • 2020-09-09
      • 1970-01-01
      • 2019-02-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多