bas*_*har 4 java spring prometheus
我试图在构造函数中使用 MeterRegistry 对象,但 Intelij 向我显示一条消息 Could not autowire. No beans of 'MeterRegistry' type found.
我正在使用这个依赖项:
implementation group: 'io.micrometer', name: 'micrometer-registry-prometheus', version: '1.3.5'
Run Code Online (Sandbox Code Playgroud)
我在 application.properties 文件中有这些属性
management.endpoint.metrics.enabled=true
management.endpoints.web.exposure.include=*
management.endpoint.prometheus.enabled=true
management.metrics.export.prometheus.enabled=true
Run Code Online (Sandbox Code Playgroud)
所以我想知道为什么 Spring 不自动装配它?我在这里缺少什么?
小智 8
您缺少执行器 JAR:
implementation("org.springframework.boot:spring-boot-starter-actuator")
Run Code Online (Sandbox Code Playgroud)
对于行家使用:
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.6.7</version>
</dependency>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8979 次 |
| 最近记录: |