代码之家  ›  专栏  ›  技术社区  ›  wosimosi

Prometheus config不适用于springboot2.3.0:未能内省类[PrometheusProperties]

  •  0
  • wosimosi  · 技术社区  · 6 年前

    2020-05-20T08:43:04.408+01:00 [APP/PROC/WEB/0] [OUT] 2020-05-20 07:43:04.407 ERROR 15 --- [ main] o.s.b.web.embedded.tomcat.TomcatStarter : Error starting Tomcat context. Exception: org.springframework.beans.factory.UnsatisfiedDependencyException. Message: Error creating bean with name 'webMvcMetricsFilter' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/web/servlet/WebMvcMetricsAutoConfiguration.class]: Unsatisfied dependency expressed through method 'webMvcMetricsFilter' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'compositeMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/CompositeMeterRegistryConfiguration.class]: Unsatisfied dependency expressed through method 'compositeMeterRegistry' parameter 1; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusMeterRegistry' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'prometheusMeterRegistry' parameter 0; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'prometheusConfig' defined in class path resource [org/springframework/boot/actuate/autoconfigure/metrics/export/prometheus/PrometheusMetricsExportAutoConfiguration.class]: Unsatisfied dependency expressed through method 'prometheusConfig' parameter 0; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'management.metrics.export.prometheus-org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties': Lookup method resolution failed; nested exception is java.lang.IllegalStateException: Failed to introspect Class [org.springframework.boot.actuate.autoconfigure.metrics.export.prometheus.PrometheusProperties] from ClassLoader [org.springframework.boot.loader.LaunchedURLClassLoader@4f3f5b24]

    enter image description here

    0 回复  |  直到 6 年前
        1
  •  24
  •   lestar cdog    6 年前

    在你的特殊情况下 micrometer-registry-prometheus 必须符合弹簧靴的千分尺核心的版本。它是 1.5.1 因为SpringBoot(执行器)在版本2.3.0中引入了这种依赖性。

      implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
    
        2
  •  5
  •   Garry Kevin    6 年前

    加上我最初不明白的答案

    必须符合弹簧靴的千分尺核心的版本。

    测微计注册prometheus包必须与io.m的版本匹配icrometer:micrometer-core version. 木卫一icrometer:micrometer-core is 由spring Acutator依赖性拉动。

    智能 : 项目窗口(cmd+1)—>外部库 enter image description here

        3
  •  1
  •   estherwn    6 年前

    当查看您包含的部分日志文件时,在我看来,多个依赖项并不是全部存在或工作正常。请参阅有关使用依赖关系管理器的Spring引导建议: https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-build-systems

    升级时,检查版本之间的releasenotes/changelog总是很有用的。

    如果您需要更多帮助,请提供有关配置的信息;

    1. pom文件(或其他依赖关系管理文件)
    2. 你认为是“普罗米修斯配置”导致了这些问题