SpringBoot2中如何配置Actuator组件
发表于:2025-11-07 作者:千家信息网编辑
千家信息网最后更新 2025年11月07日,这篇文章主要介绍"SpringBoot2中如何配置Actuator组件"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"SpringBoot2中如何配置Actua
千家信息网最后更新 2025年11月07日SpringBoot2中如何配置Actuator组件
这篇文章主要介绍"SpringBoot2中如何配置Actuator组件"的相关知识,小编通过实际案例向大家展示操作过程,操作方法简单快捷,实用性强,希望这篇"SpringBoot2中如何配置Actuator组件"文章能帮助大家解决问题。
一、Actuator简介
1、监控组件作用
在生产环境中,需要实时或定期监控服务的可用性。Spring Boot的actuator(健康监控)功能提供了很多监控所需的接口,可以对应用系统进行配置查看、相关功能统计等。
2、监控分类
Actuator 提供Rest接口,展示监控信息。
接口分为三大类:
应用配置类:获取应用程序中加载的应用配置、环境变量、自动化配置报告等与SpringBoot应用相关的配置类信息。
度量指标类:获取应用程序运行过程中用于监控的度量指标,比如:内存信息、线程池信息、HTTP请求统计等。
操作控制类:提供了对应用的关闭等操作类功能。
二、与SpringBoot2.0整合
1、核心依赖Jar包
org.springframework.boot spring-boot-starter-actuator
2、Yml配置文件
# 端口server: port: 8016spring: application: # 应用名称 name: node16-boot-actuatormanagement: endpoints: web: exposure: # 打开所有的监控点 include: "*" # 自定义监控路径 monitor # 默认值:http://localhost:8016/actuator/* # 配置后:http://localhost:8016/monitor/* base-path: /monitor endpoint: health: show-details: always shutdown: # 通过指定接口关闭 SpringBoot enabled: true # 可以自定义端口 # server: # port: 8089# 描述项目基础信息info: app: name: node16-boot-actuator port: 8016 version: 1.0.0 author: cicada
三、监控接口详解
1、Info接口
Yml文件中配置的项目基础信息
路径:http://localhost:8016/monitor/info输出:{ "app": { "name": "node16-boot-actuator", "port": 8016, "version": "1.0.0", "author": "cicada" }}2、Health接口
health 主要用来检查应用的运行状态
路径:http://localhost:8016/monitor/health输出:{ "status": "UP", "details": { "diskSpace": { "status": "UP", "details": { "total": 185496236032, "free": 140944084992, "threshold": 10485760 } } }}3、Beans接口
展示了 bean 的类型、单例多例、别名、类的全路径、依赖Jar等内容。
路径:http://localhost:8016/monitor/beans输出:{ "contexts": { "node16-boot-actuator": { "beans": { "endpointCachingOperationInvokerAdvisor": { "aliases": [], "scope": "singleton", "type": "org.springframework.boot.actuate.endpoint.invoker.cache.CachingOperationInvokerAdvisor", "resource": "class path resource [org/springframework/boot/actuate/autoconfigure/endpoint/EndpointAutoConfiguration.class]", "dependencies": ["environment"] } } }}4、Conditions接口
查看配置在什么条件下有效,或者自动配置为什么无效。
路径:http://localhost:8016/monitor/conditions输出:{ "contexts": { "node16-boot-actuator": { "positiveMatches": { "AuditAutoConfiguration#auditListener": [{ "condition": "OnBeanCondition", "message": "@ConditionalOnMissingBean" }], }}5、HeapDump接口
自动生成Jvm的堆转储文件HeapDump,可以使用监控工具 VisualVM 打开此文件查看内存快照。
路径:http://localhost:8016/monitor/heapdump
6、Mappings接口
描述 URI 路径和控制器的映射关系
路径:http://localhost:8016/monitor/mappings输出:{ "contexts": { "node16-boot-actuator": { "mappings": { "dispatcherServlets": { "dispatcherServlet": [ { "handler": "Actuator web endpoint 'auditevents'", "predicate": "{GET /monitor/auditevents || application/json]}", "details": { "handlerMethod": { "className": "org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping.Operat "name": "handle", "descriptor": "(Ljavax/servlet/http/HttpServletRequest;Ljava/util/Map;)Ljava/lang/Object;" }, "requestMappingConditions": { "consumes": [], "headers": [], "methods": ["GET"], "params": [], "patterns": ["/monitor/auditevents"], "produces": [{ "mediaType": "application/vnd.spring-boot.actuator.v2+json", "negated": false }, { "mediaType": "application/json", "negated": false }] } } } } }}7、ThreadDump接口
展示线程名、线程ID、是否等待锁、线程的状态、线程锁等相关信息。
路径:http://localhost:8016/monitor/threaddump输出:{ "threads": [{ "threadName": "DestroyJavaVM", "threadId": 34, "blockedTime": -1, "blockedCount": 0, "waitedTime": -1, "waitedCount": 0, "lockName": null, "lockOwnerId": -1, "lockOwnerName": null, "inNative": false, "suspended": false, "threadState": "RUNNABLE", "stackTrace": [], "lockedMonitors": [], "lockedSynchronizers": [], "lockInfo": null } ]}关于"SpringBoot2中如何配置Actuator组件"的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识,可以关注行业资讯频道,小编每天都会为大家更新不同的知识点。
配置
接口
监控
路径
应用
信息
输出
线程
组件
文件
功能
知识
内存
内容
基础
应用程序
指标
状态
环境
程序
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
赚钱的网络技术
电子商务网络技术名词解释
数据库hav
大连外企软件开发工程师多少钱
蚂蚁金服 ai 网络安全
阴阳师服务器哪个好
服务器怎么部署web服务
嵌入式软件开发工程师学校
网络数据库的优点
个性软件开发简历末班
数据库的连接语句左连接右连接
中国农业银行软件开发人力外包
lunux系统软件开发
新会优橙网络技术有限公司
搜狐电视直播软件开发
网络安全机构与实战
学生网络安全教育周末安全
功率合成网络技术要求
制定网络安全标准明确保护对象
网络技术与实训报告
树立正确网络安全观加强
湖州软件开发驻场
中国国家调查数据库
湖南省网络安全应急指挥中心
长沙海米网络技术
什么是数据库完整性控制
山西ios软件开发新报价
卖贷款数据库
打开关于网络安全的手抄报
玩游戏开服务器赚钱吗