gradle 如何将端点执行器/度量添加到Java项目中?

kdfy810k  于 2023-02-09  发布在  Java
关注(0)|答案(1)|浏览(113)

我实施了:
implementation("org.springframework.boot:spring-boot-starter-actuator:3.0.1")
依存关系,并添加了:management: endpoints: web: exposure: include: "*"
发送到application.yml,当我发送请求到POSTMAN时:
网址:
除指标外,所有必需的端点都可用
我该如何添加此内容?
我试着补充道:

@Autowired
    private MeterRegistry meterRegistry;
    @Bean
    public CacheMetricsRegistrar cacheMetricsRegistrar() {
        return new CacheMetricsRegistrar(meterRegistry, Lists.newArrayList(new CaffeineCacheMeterBinderProvider()));
    }

但我得到了一个错误〉进程'command 'C:/Program Files/Java/jdk-17/bin/java.exe''以非零退出值1结束

wz8daaqr

wz8daaqr1#

您是否尝试过通过yaml/properties启用它?

management.defaults.metrics.export.enabled=true
management:
  defaults:
    metrics:
      export:
        enabled: true

参考:www.example.comhttps://docs.spring.io/spring-boot/docs/current/reference/html/actuator.html#actuator.metrics

相关问题