Spring Boot有四大神器,分别是auto-configuration、starters、cli、actuator,本文主要讲actuator。actuator是spring boot提供的对应用系统的自省和监控的集成功能,可以对应用系统进行配置查看、相关功能统计等。
如何使用
在pom文件中添加spring-boot-starter-actuator依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
启动应用,日志里会打印actuator相关信息如下,
Actuator功能点说明
Spring Boot Actuator的关键特性是在应用程序里提供众多Web端点,通过它们了解应用程序 运行时的内部状况。有了Actuator,你可以知道Bean在Spring应用程序上下文里是如何组装在一 起的,掌握应用程序可以获取的环境属性信息,获取运行时度量信息的快照…… Actuator提供了13个端点,具体如表7-1所示。