用Grails重新加载bootstrap [英] Reloading bootstrap with Grails
问题描述
在没有重新启动应用程序的情况下,Grails中有没有方法可以运行BootStrap.groovy的内容? noreferrer> console
插件。我强烈推荐这个插件用于任何开发环境,因为它对于在正在运行的服务器中运行临时代码非常有用。
重新运行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)
Is there a way in Grails to run the contents of BootStrap.groovy after it has been changed without restarting the app?
You can do this with the console
plugin. I'd highly recommend this plugin for any development environment because it's so useful for running ad-hoc code inside a running server.
To rerun your BootStrap init
closure, browse to the web-based console at http://localhost:8080/appname/console
. Enter the following in the console:
def servletCtx = org.codehaus.groovy.grails.web.context.ServletContextHolder.servletContext
def myBootstrapArtefact = grailsApplication.getArtefacts('Bootstrap')[-1]
myBootstrapArtefact.referenceInstance.init(servletCtx)
这篇关于用Grails重新加载bootstrap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!