Issue
I'd like the /info
actuator endpoint from my Spring Boot (1.2.4.RELEASE) application to return the version as specified in the build.gradle
file.
In my build.gradle
file I have a line as so:
version = '0.0.1-SNAPSHOT'
I am using yaml configuration file. Right now I have the version duplicated as so in application.yml
:
info:
build:
version: 0.0.1-SNAPSHOT
Is this possible?
Solution
This exact use case is spelled out in the Boot docs:
So in your build.gradle do this
version = '0.0.1-SNAPSHOT'
processResources {
expand(project.properties)
}
Your application.yml
info:
build:
version: ${version}
Make sure to escape any spring placeholders so it doesn't conflict with Gradle. Both use ${} as the replacement token. ${key} should become \${key} . This will affect anything in src/main/resources.
Clean/build and deploy your war/jar. Don't run it from your IDE or the placeholder won't be replaced.
Answered By - jst
Answer Checked By - Robin (JavaFixing Admin)