首页 > 解决方案 > 我应该怎么做才能使“io.micrometer.core.instrument.MeterRegistry”对象自动装配

问题描述

我正在尝试在构造函数中使用 MeterRegistry 对象,但 Intelij 向我显示一条消息 Could not autowire. No beans of 'MeterRegistry' type found.

在此处输入图像描述

我正在使用此依赖项:

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

我在 application.properties 文件中有这些属性

management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true

所以我想知道为什么它不是由 Spring 自动装配的?我在这里缺少什么?

标签: javaspringprometheus

解决方案


您缺少执行器 jar: implementation("org.springframework.boot:spring-boot-starter-actuator")


推荐阅读