Display build timestamp in Spring Boot actuator info endpoint

pgman :

I am using the Spring Boot actuator to get my application's info.

I have added the Spring Boot actuator dependency in my pom.xml, and added below lines in my property file:

info:
   app:
     name: @project.name@
     description: @project.description@
     version: @project.version@

I get the values: name, description and version of my project from pom.xml. I also want to get build time and display it on the /info endpoint.

Any suggestions?

Should I also Change my pom.xml file for it? I tried using :

info.app.build-time=@build-time@

But this doesnt work.

Thanks

glytching :

You can define a timestamp Maven property in your pom.xml like so:

<properties>
   <timestamp>${maven.build.timestamp}</timestamp>
   <maven.build.timestamp.format>yyyy-MM-dd-HH:mm</maven.build.timestamp.format>
</properties>

And then reference it using the @...@ convention like so:

info:
   app:
     timestamp: @timestamp@

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=477012&siteId=1
Recommended