TOOD actuator 鉴权
beans, 查看 context 所有 bean;
conditions, conditional beans;
configprops, @ConfigurationProperties 配置
health, 查看依赖健康信息
info, 查看项目信息
env, 查看 Environment 所有信息
logfile, 获取日志文件
loggers, 获取 loggers
caches, 处理 Spring cache 相关资源, 如读取、清理
mappings, spring web url→handle method 映射关系
httptrace, 返回请求处理记录追踪
scheduledtasks, @Scheduled 执行的相关任务
通过 org.springframework.boot.actuate.autoconfigure.info.InfoEndpointAutoConfiguration 配置
public InfoEndpoint infoEndpoint(
ObjectProvider<List<InfoContributor>> infoContributors) {
return new InfoEndpoint(infoContributors.getIfAvailable(Collections::emptyList));
}
ObjectProvider 即 DefaultListBeanFactory$NestedDependencyDescriptor, 从中获取所有的
InfoContributor Bean, 展示其所有的 properties
主要有 2 个: EnvironmentInfoContributor, GitInfoContributor
EnvironmentInfoContributor$contribute 的主要功能就是把项目下所有的 info 打头的配置返回给
info endpoint
@Override
public void contribute(Info.Builder builder) {
Binder binder = Binder.get(this.environment);
binder.bind("info", STRING_OBJECT_MAP).ifBound(builder::withDetails);
}
用途, 自定义项目信息, 如
info:
endpoint: ${it-actuator.service.endpoint}
health_url: ${it-actuator.service.endpoint}${server.servlet.context-path:/}actuator/health
# swagger接口文档
api_doc:
- ${it-actuator.service.endpoint}/docs.html
- ${it-actuator.service.endpoint}/swagger-ui.html
# redis地址
redis: ${spring.redis.host}
# 保险起见,只表明是否有数据库
db_driver: ${spring.datasource.driver-class-name}
# service_name
service_name: ${spring.application.name}
学习: 注入 ObjectProvider<T> 和任意依赖有什么区别?