有没有办法做Config.groovy文件的功能,但在代码执行期间......
有点像:
class AController{
def method(){
withEnvironments{
development{
println 'This is execute just on development'
}
production {
log.debug 'This is execute just on production'
}
}
}
}
我知道我可以使用相同的效果if (Environment.current == 'development'),但是有什么东西与sintax ???
tim*_*tes 16
发现此博客文章显示了一种可能的解决方案Environment.executeForCurrentEnvironment:
import grails.util.Environment
class AController {
def method() {
Environment.executeForCurrentEnvironment {
development {
println 'This is execute just on development'
}
production {
log.debug 'This is execute just on production'
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3107 次 |
| 最近记录: |