Actuator可能大家非常熟悉,它是springboot提供对应用自身监控,以及对应用系统配置查看等功能。

springboot使用actuator的方式非常简单,只需要在项目中加入依赖spring-boot-starter-actuator,完整pom文件如下:

<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.dalaoyang</groupId>
<artifactId>springboot_actuator</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging> <name>springboot_actuator</name>
<description>springboot_actuator</description> <parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.9.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties> <dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency> <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies> <build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build> </project>

其余没有任何修改,没有新建任何类,在配置文件中加入了几条属性,配置文件如下:

##端口号
server.port=8888 ##项目信息
info.name=dalaoyang
info.server.port=${server.port}

然后启动项目可以看到:

介绍一下红框内的Actuator暴露的功能:

HTTP方法 路径 描述 鉴权
GET /autoconfig 查看自动配置的使用情况 true
GET /configprops 查看配置属性,包括默认配置 true
GET /beans 查看bean及其关系列表 true
GET /dump 打印线程栈 true
GET /env 查看所有环境变量 true
GET /env/{name} 查看具体变量值 true
GET /health 查看应用健康指标 false
GET /info 查看应用信息 false
GET /mappings 查看所有url映射 true
GET /metrics 查看应用基本指标 true
GET /metrics/{name} 查看具体指标 true
POST /shutdown 关闭应用 true
GET /trace 查看基本追踪信息 true

通过上面表格,我们可以在浏览器上访问http://localhost:8888/health可以看到如下图:

访问http://localhost:8888/info,可以看到

源码下载 :大老杨码云

个人网站:https://dalaoyang.cn

使用Actuator监控的更多相关文章

  1. springboot(十九):使用Spring Boot Actuator监控应用

    微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...

  2. (转)Spring Boot (十九):使用 Spring Boot Actuator 监控应用

    http://www.ityouknow.com/springboot/2018/02/06/spring-boot-actuator.html 微服务的特点决定了功能模块的部署是分布式的,大部分功能 ...

  3. SpringBoot系列: Actuator监控

    Sprng Boot 2 actuator变动加大, 网上很多资料都都已经过期. ============================配置项============================ ...

  4. 使用springboot actuator监控应用

    微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...

  5. spring Boot(十九):使用Spring Boot Actuator监控应用

    spring Boot(十九):使用Spring Boot Actuator监控应用 微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台 ...

  6. springboot(十九)使用actuator监控应用

    微服务的特点决定了功能模块的部署是分布式的,大部分功能模块都是运行在不同的机器上,彼此通过服务调用进行交互,前后台的业务流会经过很多个微服务的处理和传递,出现了异常如何快速定位是哪个环节出现了问题? ...

  7. SpringBoot系列九:SpringBoot服务整合(整合邮件服务、定时调度、Actuator监控)

    声明:本文来源于MLDN培训视频的课堂笔记,写在这里只是为了方便查阅. 1.概念:SpringBoot 服务整合 2.背景 在进行项目开发的时候经常会遇见以下的几个问题:需要进行邮件发送.定时的任务调 ...

  8. SpringBoot31 重识Spring01-环境搭建、Actuator监控、属性配置、多环境配置

    1 前言 1.1 学习阶段说明 从2016年9月开始接触IT,学习经历主要分为以下三个阶段 1.1.1 入门阶段 从最基础的前端技术HTML.JavaScript.CSS开始入门,再到后端技术Java ...

  9. SpringBoot 2.x (15):Actuator监控

    Actuator监控:SpringBoot自带的,对生成环境进行监控的系统 使用:既然是监控,那就不能监控一个空项目 这里我使用SpringBoot整合MyBatis的Demo: https://ww ...

  10. Spring Boot Actuator监控使用详解

    在企业级应用中,学习了如何进行SpringBoot应用的功能开发,以及如何写单元测试.集成测试等还是不够的.在实际的软件开发中还需要:应用程序的监控和管理.SpringBoot的Actuator模块实 ...

随机推荐

  1. maven添加镜像与常用配置

    maven解压后conf文件夹有个 settings.xml 在这个文件中可以配置我们的maven 配置镜像: 找到<mirrors></mirrors>找到这个节点在节点中添 ...

  2. Python基础之面向过程编程

    要求:在文件里递归找到关于包含“Python”内容的文件的绝对路径并打印出来 #定义阶段 import os,time def init(func): #装饰器的作用是使下面的生成器初始化,yield ...

  3. 阿里云服务器 http 转 https

    转载: http://blog.csdn.net/zzp961224/article/details/78934310 做个笔记 以备遗忘. 环境: 阿里云云服务器    Windows Server ...

  4. 步步为营-104-SQL语句(截取字符串)

    按照指定字符截取字符串,截取出300 业务需求:想比对图片中框线部分是否一致 第一步 从最后一个/截取到末尾 select top 1 reverse(substring(reverse(Proces ...

  5. Python推荐系统库--Surprise实战

    一.使用movieLens数据集 from surprise import KNNBasic, SVD from surprise import Dataset from surprise impor ...

  6. 20165323 实验一 Java开发环境的熟悉

    一.实验报告封面 课程:Java程序设计 班级:1653班 姓名:杨金川 学号:20165323 指导教师:娄嘉鹏 实验日期:2018年4月2日 实验时间:13:45 - 15:25 实验序号:一 实 ...

  7. Docker建立自己的私有仓库

    拉去仓库镜像 docker pull registry:latest 创建存储账户的文件夹路径 mkdir -p /{dir}/auth/ 创建用户密码信息文件 docker run --entryp ...

  8. C# 5.0 CallerMemberName CallerFilePath CallerLineNumber获取调用方法名称,路径,行号

    class Program { static void Main(string[] args) { Log("测试"); Console.Read(); } public stat ...

  9. Entity Framework介绍

    1.Entity Framework介绍 下图显示EF整体架构.现在我们来看看架构的各个组件: EDM(Entity Data Model): EDM由三个主要部分组成:概念模型,映射和存储模型.映射 ...

  10. 【AtCoder】Tenka1 Programmer Contest 2019

    Tenka1 Programmer Contest 2019 C - Stones 题面大意:有一个01序列,改变一个位置上的值花费1,问变成没有0在1右边的序列花费最少多少 直接枚举前i个都变成0即 ...