Prometheus config doesn't work with Spring boot 2.3.0: ClassNotFoundException: io.micrometer.prometheus.HistogramFlavor

限于喜欢 提交于 2020-06-17 00:08:38

问题


Application was working correctly with version 2.2.6 but as the application is upgraded to latest version of spring boot 2.3.0 it stopped working and fails during startup.

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]

Can see below class not found exception at the bottom of start trace.


回答1:


In your particular case the micrometer-registry-prometheus must be in-line with spring boot's micrometer-core's version. It is 1.5.1 because Spring Boot (Actuator) pulls that dependency in with version 2.3.0.

  implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'



回答2:


When look at the partial logfile you included, it seems to me that multiple dependencies are not all there or working correctly. Please see the Spring Boot recommendations for using a dependency manager: https://docs.spring.io/spring-boot/docs/current/reference/html/using-spring-boot.html#using-boot-build-systems

When upgrading, it is always useful to check the releasenotes/changelog between versions.

  • Release notes for 2.3: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes

  • Changelog for 2.2.7 to 2.3.0 see: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3.0-Configuration-Changelog

If you require more help, please provide information about your configuration;

  1. your pom-file(s) (or other dependency management file)
  2. the 'prometheus configuration' that you think is causing the issues


来源:https://stackoverflow.com/questions/61908419/prometheus-config-doesnt-work-with-spring-boot-2-3-0-classnotfoundexception-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!