Spring boot can create the build version info for you automatically and with a default bean to access these information. I found this link is very helpful on this and i jus tlist main points at here.
- build-info goal create the version info
<plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <executions> <execution> <goals> <goal>build-info</goal> </goals> </execution> </executions> </plugin>
2. In java code, just use
BuildProperties to get the version info. You cna then display on UI and logs.
@Autowired BuildProperties buildProperties;
3. you can even add more properties in POM to let it saved in build-info, you can refer to the link details for this.