Skip to content

Instantly share code, notes, and snippets.

@wkorando
Created April 11, 2018 18:14
Show Gist options
  • Save wkorando/71828c950dcfc71d633e184b3b025d59 to your computer and use it in GitHub Desktop.
Save wkorando/71828c950dcfc71d633e184b3b025d59 to your computer and use it in GitHub Desktop.
Example of exposing the version of spring boot being used via actuator info endpoint
@Component
public class SpringBootVersion implements InfoContributor {
@Override
public void contribute(Builder builder) {
try {
Manifest mf = new Manifest();
mf.read(Thread.currentThread().getContextClassLoader().getResourceAsStream("META-INF/MANIFEST.MF"));
Attributes atts = mf.getMainAttributes();
builder.withDetail("SpringBootVersion", atts.getValue("Spring-Boot-Version"));
} catch (Exception e) {
// Handle exception
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment