wos*_*osi 9 spring-boot-actuator prometheus spring-boot-2
应用程序在版本 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]
小智 28
在您的特定情况下,micrometer-registry-prometheus必须与 spring boot 的 micrometer-core 版本一致。这是1.5.1因为 Spring Boot (Actuator) 在 2.3.0 版本中引入了这种依赖关系。
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.5.1'
Run Code Online (Sandbox Code Playgroud)
这两个答案确实帮助我解决了我的问题。我发布此文章是为了展示如何查找 Spring Boot Starter Actuator 使用的依赖项和版本(以便查找执行器依赖项中使用的 io.micrometer:micrometer-core 版本)。
首先访问https://mvnrepository.com并搜索 Spring Boot Starter Actuator,然后单击“Spring Boot Starter Actuator”结果。然后进入后,单击您的应用程序使用的版本。
然后您将导航到如下页面
在此页面中,如果向下滚动一点,您将能够看到 spring 启动的执行器依赖项使用的所有其他依赖项(下面附有屏幕截图)。在该表(编译的依赖项)中,您将能够看到弹簧执行器使用的千分尺版本。
添加这个答案,因为我最初不明白
必须与 spring boot 的 micrometer-core 版本一致。
lestar cdog 的回答
micrometer-registry-prometheus 包必须与 io.micrometer:micrometer-core 版本的版本相匹配。io.micrometer:micrometer-core 由弹簧执行器依赖性拉动。
您可以在 IDE 中检查 io.micrometer:micrometer-core 的版本
| 归档时间: |
|
| 查看次数: |
10220 次 |
| 最近记录: |