Actuator
1、添加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.gcz</groupId> <artifactId>monitorTest</artifactId> <version>1.0-SNAPSHOT</version> <!-- springboot应用 --> <parent> <artifactId>spring-boot-starter-parent</artifactId> <groupId>org.springframework.boot</groupId> <version>2.3.0.RELEASE</version> </parent> <dependencies> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> </dependency> <!-- 使用热部署 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-devtools</artifactId> <optional>true</optional> </dependency> <!-- hibernate验证框架 --> <dependency> <groupId>org.hibernate.validator</groupId> <artifactId>hibernate-validator</artifactId> <version>6.0.17.Final</version> <scope>compile</scope> </dependency> <!-- lombok --> <dependency> <groupId>org.projectlombok</groupId> <artifactId>lombok</artifactId> </dependency> <!-- hutool --> <dependency> <groupId>cn.hutool</groupId> <artifactId>hutool-all</artifactId> <version>5.5.9</version> </dependency> <!-- actuator --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-actuator</artifactId> </dependency> </dependencies> <!-- 指定springboot仓库位置 --> <repositories> <repository> <id>milestones</id> <name>Spring Milestones</name> <url>http://code.yhsperp.com:8081/nexus/repository/maven-public/</url> <snapshots> <enabled>false</enabled> </snapshots> </repository> </repositories> </project>
2、properties
#actuator管理端口 management.server.port=8888 #修改访问根路径 2.0之前默认是/ 2.0默认是 /actuator 可以通过这个属性值修改 management.endpoints.web.base-path=/monitor #开放所有节点 默认只开启了health、info两个节点 management.endpoints.web.exposure.include=* #显示健康具体信息 默认不会显示详细信息 management.endpoint.health.show-details=always #通过接口控制应用关闭 management.endpoint.shutdown.enabled=true
3、特殊访问路径
/monitor
{ "_links": { "self": { "href": "http://127.0.0.1:8888/monitor", "templated": false }, "beans": { "href": "http://127.0.0.1:8888/monitor/beans", "templated": false }, "caches-cache": { "href": "http://127.0.0.1:8888/monitor/caches/{cache}", "templated": true }, "caches": { "href": "http://127.0.0.1:8888/monitor/caches", "templated": false }, "health": { "href": "http://127.0.0.1:8888/monitor/health", "templated": false }, "health-path": { "href": "http://127.0.0.1:8888/monitor/health/{*path}", "templated": true }, "info": { "href": "http://127.0.0.1:8888/monitor/info", "templated": false }, "conditions": { "href": "http://127.0.0.1:8888/monitor/conditions", "templated": false }, "shutdown": { "href": "http://127.0.0.1:8888/monitor/shutdown", "templated": false }, "configprops": { "href": "http://127.0.0.1:8888/monitor/configprops", "templated": false }, "env": { "href": "http://127.0.0.1:8888/monitor/env", "templated": false }, "env-toMatch": { "href": "http://127.0.0.1:8888/monitor/env/{toMatch}", "templated": true }, "loggers": { "href": "http://127.0.0.1:8888/monitor/loggers", "templated": false }, "loggers-name": { "href": "http://127.0.0.1:8888/monitor/loggers/{name}", "templated": true }, "heapdump": { "href": "http://127.0.0.1:8888/monitor/heapdump", "templated": false }, "threaddump": { "href": "http://127.0.0.1:8888/monitor/threaddump", "templated": false }, "metrics": { "href": "http://127.0.0.1:8888/monitor/metrics", "templated": false }, "metrics-requiredMetricName": { "href": "http://127.0.0.1:8888/monitor/metrics/{requiredMetricName}", "templated": true }, "scheduledtasks": { "href": "http://127.0.0.1:8888/monitor/scheduledtasks", "templated": false }, "mappings": { "href": "http://127.0.0.1:8888/monitor/mappings", "templated": false } } }
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· .NET10 - 预览版1新功能体验(一)