10

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
  • 44,936
  • 9
  • 114
  • 120
pgman
  • 493
  • 3
  • 12
  • 21
  • 1
    You don't have to use those settings in application.yml "anymore" see https://stackoverflow.com/a/55395807/32453 – rogerdpack Apr 15 '19 at 17:48

2 Answers2

12

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@
glytching
  • 44,936
  • 9
  • 114
  • 120
  • Is it also possible to find which profiles are active from pom using actuator? – pgman Sep 22 '17 at 11:04
  • Are wondering whether you can add something to your `info` endpoint which tells you which profile was active when the application was built? If so, you can set a property in your profile and then reference that property in the same way as you already reference timestamp, name, version etc. – glytching Sep 22 '17 at 11:08
  • Yes, to know active Profile when application was built. Would try it. thx – pgman Sep 22 '17 at 13:14
1

Spring Boot (1.5.10.RELEASE or 2.0.0.RELEASE) supports this using the actuator-starter with the help of some simple gradle/maven adoption now.

You can add git commit information as well as build information and customize them to some extend.

Seakayone
  • 610
  • 5
  • 11