Spring Boot Actuator Endpoints

 

常用内建的Endpoints:

beans:显示当前Spring应用上下文的Spring Bean完整列表(包含所有ApplicationContext的层次)
conditions:显示当前应用所有配置类和自动装配类的条件评估结果(包含匹配和非匹配)
env:暴露Spring ConfigurableEnvironment中的PropertySource属性
health:显示应用的健康信息
info:显示任意的应用信息。

如果需要暴露Endpoints,需在application.properties或启动参数中,增加:

management.endpoints.web.exposure.include=*

或者

management.endpoints.web.exposure.include=beans,env,health,info

 

示例:

1、在pom.xml中加入依赖

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

2、在application.properties中,加入

management.endpoints.web.exposure.include=beans,env,health,info

3、启动,日志发现

o.s.b.a.e.web.EndpointLinksResolver      : Exposing 1 endpoint(s) beneath base path '/actuator'

4、执行

http://localhost:8080/actuator/env

输出:

"java.runtime.version": {
"value": "1.8.0_51-b16"
},

"java.home": {
"value": "D:\\env\\j2ee\\java\\64bit\\java8\\jdk8\\jre"
},

"catalina.home": {
"value": "C:\\Users\\Administrator\\AppData\\Local\\Temp\\tomcat.8258922389092648732.8080"
},

{
"name": "applicationConfig: [classpath:/application.properties]",
"properties": {
"management.endpoints.web.exposure.include": {
"value": "beans,env,health,info",
"origin": "class path resource [application.properties]:1:43"
}
}

执行

http://localhost:8080/actuator/health

输出

{"status":"UP"}

 

posted @ 2019-10-26 11:17  遥远2  阅读(969)  评论(0编辑  收藏  举报