Bootstrap Classes

Configuring Start-up

Programmatic start-up configuration can be added to a Grails application by creating one or many "BootStrap" classes in the "%PROJECT_HOME%\grails-app\conf" directory:

ExampleBootStrap.groovy
class ExampleBootStrap {

     def init = { servletContext ->
         // init app
     }
     def destroy = {
         // destroy app
     }
}

The "init" closure (if it exists) is called on application load and the "destroy" closure (again if it exists) on application exit

Warning

It is not guaranteed that destroy will be called unless the application exits gracefully (for example by using the application server's shutdown command) so don't rely on it too much

See the Quick Start page for an example of using the "init" closure to build and save domain objects.

Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.