Dark theme | Light theme

March 10, 2009

Set bootstrap code for each environment in Grails 1.1

This blog post is an update of the previous blog post for Grails 1.1. We can now use the grails.util.Environment to determine which environment the application is running in. We now get the following code:

import grails.util.Environment

class BootStrap {

    def init = { servletContext ->
        switch (Environment.current) {
            case Environment.DEVELOPMENT:
                new Message(text: 'Hello world.').save()
                new Message(text: 'Another text message.').save()

     def destroy = {