- 了解Acuator
Spring Boot Acuator 提供了很多控制端点。从而了解应用程序的状况。 - Acuator监控端点及描述
端点 描述 Http方法 autoconfig 显示自动配置信息 GET beans 显示应用程序所有上下文Spring bean GET configprops 显示所有configurationProperties配置属性列表 GET dump 显示线程活动快照 GET evn 显示应用的环境变量 GET health 显示应用的程序的健康指标,这些由healthIndicator的实现类提供 GET info 显示应用信息,可以用info*属性自定义info端点公开数据 GET mappings 显示所有的url路径 GET metrics 显示应用的度量标准信息 GET shutdown 关闭应用 GET trace 显示跟踪信息(默认是100http请求 GET
- 为项目添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
测试:访问 http://127.0.0.1:8080/health
结果:
{"status":"UP"} ,返回的是UP表示正常
访问http://127.0.0.1:8080/info
结果:{}
证明info没有公开
结果:{}证明info没有公开
-
配置application.yml
info:
app:
name: "@project.name@"
description: "@project.description@"
version: "@project.version@"
spring-boot-version: "@project.parent.version@" 再次访问 http://localhost:8080/info
结果:
{"app":{"name":"microservice-simple-provider-user","description":"zjmdemo","version":"0.0.1-SNAPSHOT","spring-boot-version":"1.5.9.RELEASE"}}
访问:http://127.0.0.1:8080/autoconfig
Whitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Dec 21 21:54:04 CST 2017
There was an unexpected error (type=Unauthorized, status=401).
Full authentication is required to access this resource.
上面的是没有开启授权
在application.yml加上
management:
security:
enabled: false
就可以访问了http://127.0.0.1:8080/autoconfig 和其他未授权的都能访问了
Spring Boot Acuator 提供了很多控制端点。从而了解应用程序的状况。
端点 | 描述 | Http方法 |
autoconfig | 显示自动配置信息 | GET |
beans | 显示应用程序所有上下文Spring bean | GET |
configprops | 显示所有configurationProperties配置属性列表 | GET |
dump | 显示线程活动快照 | GET |
evn | 显示应用的环境变量 | GET |
health | 显示应用的程序的健康指标,这些由healthIndicator的实现类提供 | GET |
info | 显示应用信息,可以用info*属性自定义info端点公开数据 | GET |
mappings | 显示所有的url路径 | GET |
metrics | 显示应用的度量标准信息 | GET |
shutdown | 关闭应用 | GET |
trace | 显示跟踪信息(默认是100http请求 | GET |
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
测试:访问 http://127.0.0.1:8080/health
结果:
{"status":"UP"} ,返回的是UP表示正常访问http://127.0.0.1:8080/info 结果:{} 证明info没有公开结果:{}证明info没有公开
配置application.yml info: app: name: "@project.name@" description: "@project.description@" version: "@project.version@" spring-boot-version: "@project.parent.version@"再次访问 http://localhost:8080/info 结果:{"app":{"name":"microservice-simple-provider-user","description":"zjmdemo","version":"0.0.1-SNAPSHOT","spring-boot-version":"1.5.9.RELEASE"}} 访问:http://127.0.0.1:8080/autoconfigWhitelabel Error Page
This application has no explicit mapping for /error, so you are seeing this as a fallback.
Thu Dec 21 21:54:04 CST 2017There was an unexpected error (type=Unauthorized, status=401).Full authentication is required to access this resource.上面的是没有开启授权 在application.yml加上 management: security: enabled: false 就可以访问了http://127.0.0.1:8080/autoconfig 和其他未授权的都能访问了