如何在Grails 3中显示应用程序版本和Grails版本?

时间:2017-12-17 04:26:48

标签: grails

我在Grails 3中有一个简单的控制器,它在网页上显示应用程序版本和Grails版本。我没有收到错误,但显示的版本号也不正确。

http://docs.grails.org/latest/guide/single.html#versioning

以上是我从中取样的官方文档链接,修改了一下并测试了它。

VersionDisplayController.groovy

import grails.util.GrailsUtil

class VersionDisplayController {

    def index() {
        def appVersion = grailsApplication.metadata.getApplicationVersion()

        def grailsVersion = grailsApplication.metadata.getGrailsVersion()
        def grailsVersionThruGrailsUtil = GrailsUtil.grailsVersion

        def message = "Application Version: ${appVersion}, Grails Version: ${grailsVersion}, Grails Version Thru GrailsUtils: ${grailsVersionThruGrailsUtil}"
        render message
    }
}

输出:

Application Version: @info.app.version@, 
Grails Version: @info.app.grailsVersion@, 
Grails Version Thru GrailsUtils: 3.3.2

application.yml

grails:
    profile: web
    codegen:
        defaultPackage: evn.var.reader.demo
    spring:
        transactionManagement:
            proxies: false
    gorm:
        reactor:
            # Whether to translate GORM events into Reactor events
            # Disabled by default for performance reasons
            events: false
info:
    app:
        name: '@info.app.name@'
        version: '@info.app.version@'
        grailsVersion: '@info.app.grailsVersion@'

0 个答案:

没有答案