springboot 监控 Actuator
springboot 提供了对项目的监控功能。
1.首先添加依赖包
<!-- https://mvnrepository.com/artifact/org.springframework.boot/spring-boot-starter-actuator -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<version>2.1.3.RELEASE</version>
</dependency>
2.浏览器访问
http://127.0.0.1:8080/actuator/health 访问项目监控需要加前缀 /actuator
因为actuator默认只支持端点 /health、/info 所以访问 /env 会出现404页面。
3.配置端点
在application.properties中配置端点,
暴露部分端点
management.endpoints.web.exposure.include=info,health,beans,env
暴露所有端点
management.endpoints.web.exposure.include=*
不暴露beans端点
management.endpoints.web.exposure.exclude=beans
在上述配置中,首先使用 management.endpoints.web.exposure.include 暴露所有的端点,接着使用management.endpoints .web.exposure.exclud 排除 en 端点,这样就能够暴露除 env 外的所有 ctuator
端点了。
4.端点说明
5.端点其他配置
# Actuator 管理端口
management.server.port=8000
#暴露 有端
management.endpoints.web.exposure.include =女
#默认情况下 有端点都不启用,此时需要按需启用端点
management.endpoints.enabled-by-default=false
#启用端点 info
management.endpoint.info.enabled=true
#启用端点 beans
management.endpoint.beans.enabled=true
#启用端点 configprops
management.endpoint.configprops.enabled=true
#启用端点 env
management.endpont.env.enabled=true
#启用端点 health
management.endpoint.health.enabled=true
#启用端点 mappings
management.endpont.mappings.enabed=true
#启用端点 shutdown
management.endpoint.shutdown.enabled=true
# Actuator 端点前缀
management.endpoints.web.base -path=/manage
#将原来的 mappings 端点的请求路径修改为 urlMappings
management.endpoints.web.path-mapping.mappings=request_mappings
# Spring MVC 视图解析器配置
spring.mvc.view.prefix=/WEB-INF/jsp/
spring.mvc.view.suffix=.Jsp
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具