I want to run specific login in BootStrap class depending on development or test mode is currently used.
How can I do this?
From the documentation:
class Bootstrap {
def init = { ServletContext ctx ->
environments {
production {
// prod initialization
}
test {
// test initialization
}
development {
// dev initialization
}
}
}
...
}
import grails.util.Environment
class BootStrap {
def init = { servletContext ->
def currentEnv = Environment.current
if (currentEnv == Environment.DEVELOPMENT) {
// do custom init for dev here
} else if (currentEnv == Environment.TEST) {
// do custom init for test here
} else if (currentEnv == Environment.PRODUCTION) {
// do custom init for prod here
}
}
def destroy = {
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With