首页>代码>Spring Boot Actuator 2.3.4.RELEASE新版本实现自定义端点信息的配置实例>/custom-info-endpoint/src/main/java/com/memorynotfound/cloud/MetaDataContributor.java
package com.memorynotfound.cloud;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class MetaDataContributor implements InfoContributor {
@Autowired
private ApplicationContext ctx;
@Override
public void contribute(Info.Builder builder) {
Map<String, Object> details = new HashMap<>();
details.put("bean-definition-count", ctx.getBeanDefinitionCount());
details.put("startup-date", ctx.getStartupDate());
builder.withDetail("context", details);
}
}
最近下载更多
最近浏览更多
张朕朕 LV3
2023年9月10日
18942619496
2023年8月14日
暂无贡献等级
denliv_hui LV14
2023年6月30日
wwfl02 LV3
2023年6月13日
幻影诸 LV1
2023年6月3日
微信网友_6404797419704320
2023年3月25日
暂无贡献等级
164048465
2023年2月23日
暂无贡献等级
shizhaol LV1
2023年2月6日
yohohero LV1
2023年1月14日
38735466 LV11
2023年1月8日

