在Config.groovy中重用Grails变量 [英] Reusing Grails variables inside Config.groovy
本文介绍了在Config.groovy中重用Grails变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的 Config.groovy
中有:
//许多其他的东西在这里...
环境{
开发{
myapp.port = 7500
}
生产{
myapp .port = 7600
}
}
fizz {
buzz {
foo =Port#$ {myapp.port}
}
}
当我通过 .env = development run-app
,我的web应用程序没有错误地旋转,但是在运行时我看到 fizz.buzz.foo
是端口#[:] 。 我希望它是Port#7500。
为什么Grails看不到我的var?
$ b $另一种方法是在配置文件中简单地使用变量,如下所示: def appPort = 7500
environments {
production {
appPort = 7600
myapp.port = appPort
}
}
fizz {
buzz {
foo =Port#$ appPort
}
}
此外,当您执行运行应用程序时,您不需要发送 -Dgrails.environment = development ,它是默认的。
In my Config.groovy
I have:
// Lots of other stuff up here...
environments {
development {
myapp.port = 7500
}
production {
myapp.port = 7600
}
}
fizz {
buzz {
foo = "Port #${myapp.port}"
}
}
When I run my app via grails -Dgrails.env=development run-app
, my web app spins up without errors, but then at runtime I see that the value of fizz.buzz.foo
is "Port #[:]". I would expect it to be "Port #7500".
Why isn't Grails seeing my var?
解决方案
Another way is to simply use variables within your config file like this:
def appPort = 7500
environments {
production {
appPort = 7600
myapp.port = appPort
}
}
fizz {
buzz {
foo = "Port #$appPort"
}
}
And also, you don't need to send the -Dgrails.environment=development when you execute the run-app, it's the default one.
这篇关于在Config.groovy中重用Grails变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文