gpt4 book ai didi

grails - eventConfigureTomcat对Config.groovy的访问

转载 作者:行者123 更新时间:2023-12-02 16:00:57 31 4
gpt4 key购买 nike

Grails 2.5.0

我正在使用eventConfigureTomcat闭包通过_Events.groovy定义备用上下文根。为此,我需要像这样的代码。

eventConfigureTomcat = { tomcat ->
def newContextRoot = "/"
def newContextPath = new File("/full/path/to/context/root")
// more code below that doesn't matter for this question...
}

对于 newContextPath,我想从 Config.groovy中拉出该值(实际上是从外部配置文件中拉出它)。我尝试使用 grails.util.Holders,但在此特定事件中似乎尚未连接起来。这可能吗?

最佳答案

您可以将Config.groovy中的值设置为环境变量,然后在_Events.groovy中使用它。如果仍然需要从外部配置文件中提取文件,请在.bashrc/.bashprofile内运行bash脚本(无论您在何处定义环境变量)。

eventConfigureTomcat = { tomcat ->
String altctxroot = System.getenv("ALT_CTX_ROOT")
def newContextRoot = "/"
def newContextPath = new File("$altctxroot")
}

关于grails - eventConfigureTomcat对Config.groovy的访问,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30896946/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com