Spring Boot 如何解决“无法注册MicrometerCollector类型的Collector:cache_removals已被另一个MicrometerCollector类型的Collector使用”

1l5u6lss  于 5个月前  发布在  Spring
关注(0)|答案(1)|浏览(66)

如何解决“java.lang.IllegalArgumentException:Failed to register Collector of type MicrometerCollector:cache_removals is already in use by another Collector of type MicrometerCollector”with springboot 2.6.6
堆叠
org.springframework.beans.factory.BeanCreationException:创建名为“org.springframework. Boot .actuate.autoconfigure.metrics.cache. CacheMetricsRegistrarConfiguration”的bean时出错:通过构造函数示例化Bean失败;嵌套异常为org.springframework.beans。BeanInstantiationException:未能示例化[org.springframework. Boot .actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration]:构造函数抛出异常;嵌套异常为java.lang.IllegalArgumentException:无法注册MicrometerCollector类型的Collector:cache_removals已被org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:315)中的另一个MicrometerCollector类型的Collector使用
原因:org.springframework.beans.BeanInstantiationException:无法示例化[org.springframework. Boot .actuate.autoconfigure.metrics.cache.CacheMetricsRegistrarConfiguration]:构造函数引发异常;嵌套异常为java.lang。IllegalArgumentException:无法注册MicrometerCollector类型的Collector:cache_removals已被org.springframework.beans.BeanUtils.instantiateClass上的另一个MicrometerCollector类型的Collector使用(BeanUtils.java:224)at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:117)at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:311). 24 more Caused by:java.lang.IllegalArgumentException:无法注册MicrometerCollector类型的Collector:cache_removals已被位于io.prometheus.client.CollectorRegistry.register(CollectorRegistry. java:57)的MicrometerCollector类型的另一个Collector使用,位于io.prometheus.client.Collector.register(Collector.java:308),位于io.micrometer.prometheus.PrometheusMeterRegistry.logda$applyToCollector$16(PrometheusMeterRegistry.java:479)

anauzrmj

anauzrmj1#

我也面临着类似的问题

**Failed to register Collector of type MicrometerCollector: reactor_netty_connection_provider_total_connections is already in use by another Collector of type MicrometerCollector; nested exception is java.lang.IllegalArgumentException: Failed to register Collector of type MicrometerCollector: reactor_netty_connection_provider_total_connections is already in use by another Collector of type MicrometerCollector**

字符串
所以,错误是因为,有两个bean被创建的PrometheusMeterRegistry,第一个是由于依赖spring-boot-starter-actuator-autoconfigure和其他我是专门创建的new PrometheusMeterRegistry().所以,他们都试图注册相同的指标.因此,它是导致问题.
所以,我删除了prometheus注册表的bean,这是我显式创建的,解决了我的问题。

相关问题