使用Grails重新加载引导程序

时间:2012-05-03 21:05:23

标签: grails

Grails是否有办法在不重新启动应用程序的情况下更改后运行BootStrap.groovy的内容?

1 个答案:

答案 0 :(得分:15)

您可以使用console plugin执行此操作。我强烈推荐这个插件用于任何开发环境,因为它对于在正在运行的服务器中运行ad-hoc代码非常有用。

要重新运行BootStrap init闭包,请浏览http://localhost:8080/appname/console处的基于Web的控制台。在控制台中输入以下内容:

def servletCtx = org.codehaus.groovy.grails.web.context.ServletContextHolder.servletContext
def myBootstrapArtefact = grailsApplication.getArtefacts('Bootstrap')[-1]
myBootstrapArtefact.referenceInstance.init(servletCtx)