1

我在目录config.properties下有一个文件conf

并在上面的文件中有一个这样的条目:grails.tomcat.version = 2.2.4.

如何在BuildConfig.groovy文件中使用此值?

认为:

plugins = {
    build ":tomcat:{here i want to use the config value}"
}
4

1 回答 1

4

您可以properties按如下方式读取文件:

plugins {
    def props = new Properties()
    new File("grails-app/conf/config.properties").withReader{
        props.load(it)
    }
    def slurp = new ConfigSlurper().parse(props)

    build ":tomcat:$slurp.grails.tomcat.version"
}

如果您只有从属性文件中使用的单个条目,我看不到它的值。我宁愿在Config.groovy.

于 2013-09-19T04:13:43.167 回答