Springboot中怎么实现actuator生产就绪功能

这篇文章主要讲解了Springboot中怎么实现actuator生产就绪功能,内容清晰明了,对此有兴趣的小伙伴可以学习一下,相信大家阅读完之后会有帮助。

Spring Boot包含许多附加功能,可帮助您在将应用程序投入生产时对其进行监视和管理。可以选择使用HTTP端点或JMX管理和监视您的应用程序。审核,运行状况和指标收集可以自动应用于您的应用程序。

Springboot Actuator,它提供了很多生产级的特性,比如说监控和度量spring boot应用程序。Actuator的这些特性可以通过众多的REST断点,远程shell和JMX获得。

只有基于Spring MVC的应用程序才可以通过HTTP终端来监控应用程序的运行指标。

使用Spring Boot actuator配置相关依赖:

<dependencies>
  <dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-actuator</artifactId>
  </dependency>
</dependencies>

Web应用默认使用8080端口运行。一旦这个应用启动了,你可以通过http://localhost:8080/actuator来展示所有通过HTTP暴露的endpoints。

默认情况只暴露/actuator/health与/actuator/info这两个endpoint,可能通过修改spring的配置文件application.properties (或application.yml 配置文件名根据项目实际情况而不同)增加 management.endpoints.web.exposure.include=* 一行配置内容暴露其他的endpoint(除了shutdown这个endpoint外)

增加management.endpoint.shutdown.enabled=true 配置可暴露shutdown。

/actuator/health

看完上述内容,是不是对Springboot中怎么实现actuator生产就绪功能有进一步的了解,如果还想学习更多内容,欢迎关注行业资讯频道。