zoukankan      html  css  js  c++  java
  • SpringBoot系列:五、SpringBoot使用Actuator

    Actuator为springboot提供了运行状态监控的功能

    通过集成它我们可以试试获取到应用程序的运行信息

    首先,在pom.xml中引入起步依赖

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

    然后在配置文件中添加配置节点,注意如果有多个配置文件需要添加在application.yml中
    并且把actuator端口设置为其他端口,如果不设置的话会和程序共享一个端口,可以通过endpoint
    来制定不通配置节点的特殊配置,例如我们这里开启了可以通过actuator来关闭应用程序
    设置可以访问的节点  * 为全部
    management:
      endpoints:
        web:
          exposure:
            include: "*"
    
      endpoint:
        health:
          show-details: always
        shutdown:
          enabled: true
      server:
        port: 9001

    设置完成后启动程序,我们可以看到现在有两个端口正在被监听,一个是应用程序的端口一个是actuator的端口

     通过访问actuator的API可以获取目前应用程序的运行信息'

  • 相关阅读:
    centos7下查看端口是否被占用
    centos7通过yum安装redis
    centos7下mysql远程连接
    centos7通过yum安装JDK1.8
    Jwt系列2:使用
    Jwt系列1:简介
    Python基础语法
    排序
    利用MultipartFile来进行文件上传
    服务器端跳转和客户端跳转
  • 原文地址:https://www.cnblogs.com/Tassdar/p/11743519.html
Copyright © 2011-2022 走看看