0

I'm using spring boot and was trying to retrieve the current application version. (basically the version in the pom.xml)

On the spring boot ref site I can see there is a ${application.version} that is meant to have the version present in the MANIFEST file. (I have checked in the jar, and the I indeed can see this line

Implementation-Version: 0.1.1-SNAPSHOT

but in the code when I try to retrieve ${application.version} (using @Value throws an error saying the prop cannot be found) and using env.getProperty("application.version") returns null.

Is there anything I need to setup in order to be able to use this prop ?

Johny19
  • 5,364
  • 14
  • 61
  • 99

2 Answers2

1

I found the application.version property only works in banner.txt. I read the Implementation-Version from manifest file directly, see How to read my META-INF/MANIFEST.MF file in a Spring Boot app?

Community
  • 1
  • 1
samsong8610
  • 1,007
  • 9
  • 14
0

The application.version is only available when you are run the application as built jar file. java -jar springboot.jar When running within a editor you will not have the version available.

Shibashis
  • 8,023
  • 3
  • 27
  • 38