前言:
在spring boot的舊版本中,監控端點(如/env)是默認開啟的,所以只要項目正常啟動,就能通過url獲取信息。可是在2.0版本以后,由於安全性考慮,除了/health和/info的端點,默認都是不暴露的。
那么,要怎么開啟監控點呢?
啟動、暴露端點的配置代碼如下:(放在application.properties文件中)
#--------------關於actuator暴露端點的配置(version: Spring-Boot-2.0)----------------- # 說明: # 1.要通過actuator暴露端點,必須同時是啟用(enabled)和暴露(exposed)的 # 2.所有除了/health和/info的端點,默認都是不暴露的 # 3.所有除了/shutdown的端點,默認都是啟用的 # PS.生產環境由於安全性的問題,注意不要暴露敏感端點 # 設置暴露所有端點 management.endpoints.web.exposure.include=* # 設置單個端點(/shutdown)可用 #management.endpoint.shutdown.enabled=true # 設置暴露所有端點,除了env #management.endpoints.web.exposure.include=* #management.endpoints.web.exposure.exclude=env
