關注公眾號:程序猿王國 持續更新,每日分享
准備環境:
一個springBoot工程
第一步:添加以下依賴
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
第二步:在properties文件中配置actuator權限配置(否則訪問一些暴露的監控信息會報401,很多博客里沒有這一項,讓很多人誤解了)
management.security.enabled=false
簡單介紹:
ID | 描述 | 敏感(Sensitive) |
---|---|---|
autoconfig | 顯示一個auto-configuration的報告,該報告展示所有auto-configuration候選者及它們被應用或未被應用的原因 | true |
beans | 顯示一個應用中所有Spring Beans的完整列表 | true |
configprops | 顯示一個所有@ConfigurationProperties的整理列表 | true |
dump | 執行一個線程轉儲 | true |
env | 暴露來自Spring ConfigurableEnvironment的屬性 | true |
health | 展示應用的健康信息(當使用一個未認證連接訪問時顯示一個簡單的’status’,使用認證連接訪問則顯示全部信息詳情) | false |
info | 顯示任意的應用信息 | false |
metrics | 展示當前應用的’指標’信息 | true |
mappings | 顯示一個所有@RequestMapping路徑的整理列表 | true |
shutdown | 允許應用以優雅的方式關閉(默認情況下不啟用) | true |
trace | 顯示trace信息(默認為最新的一些HTTP請求) | true |
接下來實際操作一下吧(簡單舉個栗子):
beans(顯示一個應用中所有Spring Beans的完整列表)
啟動springBoot應用后,瀏覽器訪問localhost:8080/項目名/beans,瀏覽器就會顯示Bean列表
health
首先需配置
endpoints.health.sensitive=false
瀏覽器訪問localhost:8080/項目名/health,瀏覽器就會顯示健康信息
剩下的我就不一一列出來了,希望能幫到各位