美文网首页
使用SpringActuator为SpringBoot项目添加健

使用SpringActuator为SpringBoot项目添加健

作者: 阿乐_822e | 来源:发表于2025-02-04 10:48 被阅读0次

日常运维中,常常会遇到监控微服务状态的场景。在使用Srping Boot构建的项目中,Spring Actuator提供了开箱即用的运维端点。
使用方法非常简单,在pom文件中加入依赖如下:

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

上面省略了<version>标签,让Maven自动使用Spring Boot父POM中定义的版本
重新编译后,对于Srping Boot2以上的版本,访问:localhost:8012/actuator/health
会返回:{"status":"UP"}
如果是Srping Boot2以下的版本,默认是访问:http://localhost:8012/health

image.png

相关文章

网友评论

      本文标题:使用SpringActuator为SpringBoot项目添加健

      本文链接:https://www.haomeiwen.com/subject/ndriujtx.html