Prometheus 配置不适用于 Spring 引导 2.3.0:ClassNotFoundException:io.micrometer.prometheus.HistogramFlavor
Prometheus config doesn't work with Spring boot 2.3.0: ClassNotFoundException: io.micrometer.prometheus.HistogramFlavor
应用程序在 2.2.6 版中正常工作,但随着应用程序升级到最新版本的 spring boot 2.3.0,它停止工作并在启动过程中失败。
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]
可以看到下面class not found exception at the bottom of start trace。
当查看您包含的部分日志文件时,在我看来,多个依赖项并不全部存在或无法正常工作。请参阅 Spring 使用依赖管理器的启动建议:https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-build-systems
升级时,检查版本之间的 releasenotes/changelog 总是有用的。
2.3 的发行说明:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes
2.2.7 到 2.3.0 的变更日志请参阅:
https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-Configuration-Changelog
如果您需要更多帮助,请提供您的配置信息;
- 您的 pom 文件(或其他依赖管理文件)
- 您认为导致问题的'prometheus configuration'
在您的特定情况下,micrometer-registry-prometheus 必须与 spring 启动的千分尺核心版本一致。它是 1.5.1
因为 Spring Boot (Actuator) 在 2.3.0 版本中引入了依赖关系。
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
添加这个答案,因为我最初不明白
must be in-line with spring boot's micrometer-core's version.
lestar cdog 的回答
micrometer-registry-prometheus 包必须匹配 io.micrometer:micrometer-core 版本。 io.micrometer:micrometer-core 被 spring 执行器依赖拉动。
您可以在您的 IDE
中查看版本 io.micrometer:micrometer-core
IntelliJ:
项目 window(cmd + 1) -> 外部库
应用程序在 2.2.6 版中正常工作,但随着应用程序升级到最新版本的 spring boot 2.3.0,它停止工作并在启动过程中失败。
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]
可以看到下面class not found exception at the bottom of start trace。
当查看您包含的部分日志文件时,在我看来,多个依赖项并不全部存在或无法正常工作。请参阅 Spring 使用依赖管理器的启动建议:https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-build-systems
升级时,检查版本之间的 releasenotes/changelog 总是有用的。
2.3 的发行说明: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes
2.2.7 到 2.3.0 的变更日志请参阅: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-Configuration-Changelog
如果您需要更多帮助,请提供您的配置信息;
- 您的 pom 文件(或其他依赖管理文件)
- 您认为导致问题的'prometheus configuration'
在您的特定情况下,micrometer-registry-prometheus 必须与 spring 启动的千分尺核心版本一致。它是 1.5.1
因为 Spring Boot (Actuator) 在 2.3.0 版本中引入了依赖关系。
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
添加这个答案,因为我最初不明白
must be in-line with spring boot's micrometer-core's version.
lestar cdog 的回答
micrometer-registry-prometheus 包必须匹配 io.micrometer:micrometer-core 版本。 io.micrometer:micrometer-core 被 spring 执行器依赖拉动。
您可以在您的 IDE
中查看版本 io.micrometer:micrometer-coreIntelliJ:
项目 window(cmd + 1) -> 外部库