Actuator
小于 1 分钟javaspring
依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
最简使用
添加依赖后不做任何配置,默认只开启两个 endpoint: /actuator/health , /actuator/info 可在配置文件中配置
management:
endpoints:
web:
exposure:
include: *
表示开启所有 endpoint ,关于配置见下面
# 可以這樣寫,就會開啟所有endpoints(不包含shutdown)
management.endpoints.web.exposure.include=*
# 也可以這樣寫,就只會開啟指定的endpoint,因此此處只會再額外開啟/actuator/beans和/actuator/mappings
management.endpoints.web.exposure.include=beans,mappings
# exclude可以用來關閉某些endpoints
# exclude通常會跟include一起用,就是先include了全部,然後再exclude /actuator/beans這個endpoint
management.endpoints.web.exposure.exclude=beans
management.endpoints.web.exposure.include=*
# 如果要開啟/actuator/shutdown,要額外再加這一行
management.endpoint.shutdown.enabled=true
