Getting the Gradle.build version into Spring Boot

前端 未结 4 1730
广开言路
广开言路 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条回答
  •  轮回少年
    2021-01-03 23:45

    You can also add this in build.gradle :

    springBoot {    
        buildInfo() 
    }
    

    Then, you can use BuildProperties bean :

    @Autowired
    private BuildProperties buildProperties;
    

    And get the version with buildProperties.getVersion()

提交回复
热议问题