spring-boot-starter-actuator 作用及基本使用


使用 spring-boot-starter-actuator 可以用於檢測系統的健康情況、當前的Beans、系統的緩存等,具體可檢測的內容參考下面的鏈接: https://docs.spring.io/spring-boot/docs/2.6.1/reference/htmlsingle/#actuator.endpoints.exposing

使用方法,在pom.xml 文件中引入spring-boot-starter-actuator依賴:

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

默認情況下,通過web端只可訪問http://localhost:8080/actuator/health ,可在application.properties中配置訪問的uri、權限、端口等

# 訪問端口
management.server.port=8081
# 根路徑
management.endpoints.web.base-path=/actuator/z
# web端允許的路徑
management.endpoints.web.exposure.include=*

通過以上配置,開放了web端的所有訪問,可通過訪問http://localhost:8081/actuator/z/beans 來查看系統中的beans


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM