0

我有一个带有 Spring Boot 2 的微服务应用程序,它使用我自己的库通过执行器功能将新端点传播到自身 - 我自己的执行器实现了 MvcEndpoint 接口,并包含从 application.yml 获取真实 API 映射的“路径”变量使用这个库的微服务。

但是在我将我的库重新编码为 Spring Boot 2 之后,我遇到了一个问题 - @Endpoint注释上的id属性仅包含常量值(作为每个注释属性),并且我还没有找到将执行器端点的 API 路径更改为某些东西的方法像' /api/v1/my-service/my-actuator-endpoint '。

我试图在我的微服务 application.yml 中写这个:

endpoints:
  my-actuator-endpoint:
    path: /api/v1/my-service/my-actuator-endpoint

但是这个端点仍然只能从 /my-actuator-endpoint 访问,这意味着只能通过它的 id。

如何通过 /api/v1/my-service/my-actuator-endpoint 等自定义路径访问它,该路径将在 application.yml 中配置?

4

2 回答 2

0

问题已解决,需要将此属性添加到 application.yml:

management:
  endpoints:
    web:
      path-mapping:
        my-actuator-endpoint: api/v1/my-service/my-actuator-endpoint
于 2019-10-19T12:54:41.000 回答
0

您可以通过在属性文件中设置配置来公开执行器端点,如下所示

management.context-path=/manage
于 2019-10-19T12:55:59.020 回答