Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4084940
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:30:16+00:00 2026-05-20T18:30:16+00:00

grails.util.Environment , defines a number of preconfigured environments DEVELOPMENT PRODUCTION TEST CUSTOM When running

  • 0

grails.util.Environment, defines a number of preconfigured environments

  • DEVELOPMENT
  • PRODUCTION
  • TEST
  • CUSTOM

When running a Grails command, the environment to use can be specified using a -Denv flag, e.g. grails run-app -Denv=test. You can also specify a block of code that is specific to a certain environment using closures such as:

environments {
    production {
        grails.serverURL = "http://www.changeme.com"
    }
    development {
        grails.serverURL = "http://localhost:8080/${appName}"
    }
    test {
        grails.serverURL = "http://localhost:8080/${appName}"
    }
}

These environment-specific closures can be used in Bootstrap.groovy and Config.groovy, are there other places?

Also, is it possible for me to define my own environment, e.g. PRE_PRODUCTION, such that it will work with the closures above and the -Denv flag?

Finally, can the CUSTOM environment be used with the -Denv flag?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T18:30:17+00:00Added an answer on May 20, 2026 at 6:30 pm

    These environment-specific closures
    can be used in Bootstrap.groovy and
    Config.groovy, are there other places?

    I don’t think so… For other places, you would need to use the Generic Per Environment Execution block

    Environment.executeForCurrentEnvironment {
        production {
            // do something in production
        }
        development {
            // do something only in development
        }
        pre_production {
            // do something for your custom environment
        }
    }
    

    Also, is it possible for me to define
    my own environment, e.g.
    PRE_PRODUCTION, such that it will work
    with the closures above and the -Denv
    flag?

    Yeah, you should be able to just declare -Dgrails.env=pre_production and include the pre_production block in Bootstrap.groovy or Config.groovy (or a custom grails.util.Environment block as above)

    edit

    As you can see in the Grails source for Environment, this sort of custom environment will enumerate to Environment.CUSTOM, and then in the Environment.executeForCurrentEnvironment block, it will check against CUSTOM, and the name of the custom environment

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've built a Maven Grails project which can be build fine using command mvn
Using Grails database-migration I have a table in production defined like so: +--------------+------------+------+-----+---------+----------------+ |
In Grails, one can 'bindData' in controller: Book b = new Book() bindData(b, params)
I have a Grails web application running on a german localized machine. How does
I would like to use subreports with grails jasper plugins, I followed the manual
Grails has a war command to create a Web Application Archive (WAR) file which
Since upgrading to Grails 2.0, adding the line: org.hsqldb.util.DatabaseManager.main() to BootStrap.groovy doesn't bring up
Grails 1.3.6 Tomcat6 I created a production ROOT.war. Deleted the default tomcat ROOT directory.
After installing export plugin i can not run grails application and get this java.lang.LinkageError:
I'm using Grails 1.3.2 in NetBeans. I have a very simple unit test that

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.