【黑马程序员SpringBoot2全套视频教程,springboot零基础到项目实战(spring boot2完整版)】
之前我们已经学习完了,SpringBoot Admin 这个平台它是通过获取请求信息然后做展示这么一个平台。
最后留了个问题
其他的端点都或多或少的提供了一些信息,就这个info ,啥也没有【这个信息怎么去操作维护?】
【自定义】
打开SSMP 的配置文件
info:author: DingJiaxiong
笔者这样配置完后,面板并没有变化
笔者谷歌了下
OK,我试试
management:info:env:enabled: true
加上这个配置
再次重启
OK,这次就有了
还可以读取pom 文件的信息
info:appName: @project.artifactId@author: DingJiaxiong
再次重启
查看面板
妙啊
还可以自定义很多信息
info:appName: @project.artifactId@version: @project.version@company: 我永远爱你author: DingJiaxiong
挺好
如果想要加入动态获取的信息,像下面这样
先来一个配置类
package com.dingjiaxiong.actuator;import org.springframework.boot.actuate.info.Info;
import org.springframework.boot.actuate.info.InfoContributor;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;import java.util.HashMap;
import java.util.Map;/*** ClassName: InfoConfig* date: 2022/10/23 21:48** @author DingJiaxiong*/@Component
public class InfoConfig implements InfoContributor {//这个方法中写的东西就可以进到信息区域中了@Overridepublic void contribute(Info.Builder builder) {builder.withDetail("runTime",System.currentTimeMillis());Map infoMap = new HashMap();infoMap.put("buildTime","2022");builder.withDetails(infoMap);}
}
OK,直接重启启动
这样数据也上来了
回顾一下