DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Grails Goodness: Skip Bootstrap Code

Grails Goodness: Skip Bootstrap Code

Learn how you can skip the execution of Bootstrap classes in your code with a simple system property.

Hubert Klein Ikkink user avatar by
Hubert Klein Ikkink
·
Oct. 21, 16 · Java Zone · Tutorial
Like (1)
Save
Tweet
5.94K Views

Join the DZone community and get the full member experience.

Join For Free

Grails normally will run any *Bootstrap classes at startup. A Bootstrap class has an init and destroy closure. The init closure is invoked during startup and destroy when the application stops. The class name must end with Bootstrap and be placed in the grails-app/init folder. Ever since Grails 3.2, we can skip the execution of Bootstrap classes by setting the Java system property grails.bootstrap.skip with the value true.

In the following example Bootstrap class, we simply add a println to see the effect of using the system property grails.bootstrap.skip:

// File: grails-app/init/mrhaki/Bootstrap.groovy
package mrhaki

class Bootstrap {
    def init = { servletContext ->
        println "Run Bootstrap"
    }

    def destroy = {
    }
}

First, we build the application, and then start it from the generated WAR file:

$ gradle build
...
:build

BUILD SUCCESSFUL

Total time: 22.235 secs
$ java -jar build/libs/sample-app-0.1.war
Run Bootstrap
Grails application running at http://localhost:8080 in environment: production

Next, we use the Java system property grails.bootstrap.skip:

$ java -Dgrails.bootstrap.skip=true -jar build/libs/sample-app-0.1.war

Notice the println statement from Bootstrap.groovy is not invoked anymore.

Grail (web browser) Bootstrap (front-end framework)

Published at DZone with permission of Hubert Klein Ikkink, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Testing Your Infrastructure as Code Using Terratest
  • Common Types Of Network Security Vulnerabilities In 2022
  • Anypoint CLI Commands in MuleSoft
  • When Disaster Strikes: Production Troubleshooting

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo