本文介绍了如何从Config.groovy中的其他配置变量引用一个配置变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

例如:

Config.groovy:

  / / ... 
grails.variable1 =a
grails.varibale2 =$ {grails.variable1} bc
// ...

2.2.3。对于旧版本的grails,请使用solution @tim_yates建议

  def rootVar ='a'
grails.variable1 = rootVar
grails.varibale2 =$ {rootVar} bc

或者你可以通过闭包(未经测试)来完成:

  grails.variable1 ='a'
grails.varibale2 = { - > $ {grails.variable1} bc}()


For example:

Config.groovy:

// ...
grails.variable1 = "a"
grails.varibale2 = "${grails.variable1}bc"
//...

UPDATE 1

Way shown above works with grails 2.2.3. For older versions of grails please use solution @tim_yates suggested

解决方案

You need to declare a variable:

def rootVar = 'a'
grails.variable1 = rootVar
grails.varibale2 = "${rootVar}bc"

Or you might be able to do it via a closure (not tested):

grails.variable1 = 'a'
grails.varibale2 = { -> "${grails.variable1}bc" }()

这篇关于如何从Config.groovy中的其他配置变量引用一个配置变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-11 07:11