前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >23-SpringBoot监控-actuator基本使用

23-SpringBoot监控-actuator基本使用

作者头像
Devops海洋的渔夫
发布2022-03-23 16:17:29
2430
发布2022-03-23 16:17:29
举报
文章被收录于专栏:Devops专栏Devops专栏

23-SpringBoot监控-actuator基本使用

SpringBoot监控-actuator基本使用

SpringBoot自带监控功能Actuator,可以帮助实现对程序内部运行情况监控,比如监控状况、Bean加载情况、配置属性、日志信息等。

使用步骤

①导入依赖坐标

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

②访问http://localhost:8080/acruator

案例演示

1.初始化项目 springboot-actuator

勾选需要的依赖:

pom.xml 配置如下:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <!-- springboot父工程   -->
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.6.4</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>

    <!-- 工程坐标   -->
    <groupId>com.lijw</groupId>
    <artifactId>springboot-actuator</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <!-- 工程信息   -->
    <name>springboot-actuator</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>1.8</java.version>
    </properties>

    <!-- 工程依赖   -->
    <dependencies>
        <!--  actuator 监控起步依赖    -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <!--  web 起步依赖    -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <!--  test 起步依赖    -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>

</project>
2.启动服务,查看 actuator 信息

可以通过 /actuator 查看暴露的 endpoint,访问:

本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-03-08,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 海洋的渔夫 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 23-SpringBoot监控-actuator基本使用
    • SpringBoot监控-actuator基本使用
      • 使用步骤
      • 案例演示
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档