grails中特定于环境的web.xml? [英] Environment-specific web.xml in grails?

查看:77
本文介绍了grails中特定于环境的web.xml?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在grails中构建特定于环境的 web.xml 条目的最佳方式是什么?

What's the best way to build environment-specific web.xml entries in grails?

我需要

有什么想法?

推荐答案

您可以使用事件处理函数为'WebXmlEnd'事件创建 scripts / _Events.groovy ,这个事件会在Grails和插件完成更改后触发。使用普通的搜索/替换或通过解析XML来更新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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆