我已经在我的springboot应用程序中结合了git-commit-id-maven-plugin来捕获提交版本id。/actuator/info端点现在返回以下内容
{"git":{"branch":"feature/AddActuator","commit":{"id":"ebd8af6","time":"2022-05-19T18:15:00Z"}}}我还想将主机名与上面的响应一起添加到/info中,以便在分布式环境中确认所有已部署主机中的哪个版本。
任何帮助都非常感谢。
发布于 2022-08-29 00:14:52
为了添加附加的/info变量,可以注入将显示主机名的附加InfoContrubitor:
@Component
public class HostnameContributor implements InfoContributor {
@Override
public void contribute(Info.Builder builder) {
try {
builder.withDetail("hostname", InetAddress.getLocalHost().getHostName());
} catch (UnknownHostException exception) {
builder.withDetail("hostname", "unknown");
}
}
}https://stackoverflow.com/questions/72327149
复制相似问题