Cover by Burt Beckwith

Safari, the world’s most comprehensive technology and business learning platform.

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required

O'Reilly logo

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 ...

Find the exact information you need to solve a problem on the fly, or go deeper to master the technologies and skills you need to succeed

Start Free Trial

No credit card required