Getting the Gradle.build version into Spring Boot

前端 未结 4 1708
广开言路
广开言路 2021-01-03 23:35

I\'m trying to display the application version of my Spring Boot application in a view. I\'m sure I can access this version information, I just don\'t know how.

I tr

4条回答
  •  -上瘾入骨i
    2021-01-03 23:51

    I've resolved this by adding into application.yml the following:

    ${version?:unknown}
    

    It also work from cli:gradle bootRun and also from IntelliJ and you don't have to call the Gradle task processResources before launching in IntelliJ or use spring profiles.

    This work with Gradle ver:4.6 and also Spring Boot ver: 2.0.1.RELEASE. Hope it helps ;)

提交回复
热议问题