O'Reilly logo

Programming Grails by Burt Beckwith

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 7. Configuration

Grails uses a “convention over configuration” approach, but of course that doesn’t mean that everything follows a convention. You should use the conventions where they make sense and override defaults as needed. And, beyond configuring core functionality, Grails has several configuration files under the grails-app/conf folder where you configure application settings, Spring bean definitions, library and plugin dependencies, and so on. Quite often, as an application grows, these configuration files can get large and unwieldy, so in this chapter, we discuss various approaches for partitioning and organizing various config files.

External config Files

The Config.groovy file that’s generated by the create-app script contains this commented-out code at the top:

// locations to search for config files that get merged into the main config;
// config files can be ConfigSlurper scripts, Java properties files, or classes
// in the classpath in ConfigSlurper format

// grails.config.locations = [
//      "classpath:${appName}-config.properties",
//      "classpath:${appName}-config.groovy",
//      "file:${userHome}/.grails/${appName}-config.properties",
//      "file:${userHome}/.grails/${appName}-config.groovy"]

// if (System.properties["${appName}.config.location"]) {
//    grails.config.locations << "file:" +
//         System.properties["${appName}.config.location"]
// }

This provides a great way of defining one or more external config files that get merged into the main config that’s defined in ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required