Spring Boot : 2.0.3
POM文件中加入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
</dependency>
启动Tomcat时,在 console 里增加了以下的日志
1.访问:http://localhost:8080/actuator/health,返回
{
"status": "UP"
}
2. 访问: http://localhost:8080/actuator/info,返回
{}
通过SpringBoot 官网得知, 对于Web 下查看,只有health 和 info 两个endpoint 是enable 的
https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#production-ready-enabling
在src\main\resources\application.properties 中增加下面的内容,打开所有的 endpoint, 并重新启动,在日志里可以看到下面内容
management.endpoints.web.exposure.include=*
可以已经exposing 14 endpoints

本文介绍如何在SpringBoot 2.0.3版本中配置POM文件,加入spring-boot-starter-actuator和spring-webmvc依赖,实现Web环境下查看health和info endpoint。通过在application.properties中设置management.endpoints.web.exposure.include=*,可开启所有endpoint,便于监控和管理。
2092

被折叠的 条评论
为什么被折叠?



