Created
April 11, 2018 18:14
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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