Odinodin
Odinodin

Reputation: 2177

Reloading bootstrap with Grails

Is there a way in Grails to run the contents of BootStrap.groovy after it has been changed without restarting the app?

Upvotes: 11

Views: 1946

Answers (1)

ataylor
ataylor

Reputation: 66059

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)

Upvotes: 15

Related Questions