grails 中特定于环境的 web.xml? [英] Environment-specific web.xml in grails?
本文介绍了grails 中特定于环境的 web.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 grails 中构建特定于环境的 web.xml
条目的最佳方法是什么?
What's the best way to build environment-specific web.xml
entries in grails?
我只需要对生产进行某些修改,因为它们会中断本地运行.
I need to make certain modifications for production only, as they break running locally.
有什么想法吗?
推荐答案
您可以为 'WebXmlEnd' 事件创建 scripts/_Events.groovy
事件处理程序,该事件在 Grails 和插件中触发一次已完成更改.使用简单的搜索/替换或通过解析 XML 的 DOM 方法更新 XML 并写出更新的文件:
You can create scripts/_Events.groovy
with an event handler for the 'WebXmlEnd' event which is fired once Grails and the plugins have finished making their changes. Update the XML with plain search/replace or via DOM methods by parsing the XML and write out the updated file:
import grails.util.Environment
eventWebXmlEnd = { String filename ->
if (Environment.current != Environment.PRODUCTION) {
return
}
String content = webXmlFile.text
// update the XML
content = ...
webXmlFile.withWriter { file -> file << content }
}
这篇关于grails 中特定于环境的 web.xml?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文