在grails应用程序的运行时修改groovy代码 [英] Modifying groovy code at runtime in grails application

查看:100
本文介绍了在grails应用程序的运行时修改groovy代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用嵌入式jetty服务器(tomcat for grails 1.2)运行我的grails应用程序时,我可以在运行时即时更改我的控制器,服务和其他java文件,而无需重新启动应用程序。我如何才能在部署在Tomcat(或任何服务器)上的应用程序上实现同样的功能。我已经观察到webapps下的爆炸war文件夹有gsp文件,但不是groovy文件。 解决方案

完成Eric的答案,您无法更改即时生产环境中的源代码。但是,如果你真的想在实时修改你的代码,你可以:


  1. 更改groovy类,编译它,替换.class文件在爆炸的战争文件夹中,然后重新启动tomcat(我知道,这很痛苦,但我不知道更好的方法)

  2. 对于gsp文件,有一个技巧。添加到您的 Config.groovy 文件的以下属性: grails.gsp.enable.reload = true 。这将允许您在飞行中更改您的gsp文件。小心,因为它会损害性能。详情请参阅


When I run my grails application using embedded jetty server(tomcat for grails 1.2), I can make changes to my controllers, services and other java files on-the-fly at runtime without restarting the application. How can I achieve the same functionality on my application deployed on Tomcat(or any server) for that matter. I have observed the exploded war folder under webapps has gsp files but not the groovy files.

Completing Eric's answer, you cannot change on the fly the source code in production environment. However, if you really want to modify your code in live you can:

  1. Change the groovy class, compile it, replace the .class file in the exploded war folder and restart tomcat (I know, I know, it's painful but I don't know a better way)
  2. For gsp files, there is a trick. add to your Config.groovy file the following property : grails.gsp.enable.reload=true. This will allow you to change on the fly your gsp file. Be careful because it will hurt performance. See here for details

这篇关于在grails应用程序的运行时修改groovy代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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