Grails - Convention over Configuration



In grails, "convention over configuration" approach is followed. In this way, most of the configurations are automatically controlled using name and locations of the files of the grails project instead of any configuartion file. For example, when we created a new project as in Grails - Creating Application chapter, Grails created a project structure as shown below −

Project Structure

Key Directories

Following is the breakup of key directories under a Grails project −

  • grails-app − Root Directory carrying the groovy sources.

    Grails App Structure
    • conf − configuration sources

    • controllers − Web controller classes

    • domain − application domain specific model classes

    • i18n − Internationalization (i18n) support sources

    • service −Service layer classes

    • taglib −taglib libraries

    • utils −contains grails specific utilities

    • views −contains Groovy Server Pages (GSP) or JSON Views

    • commands −to contain custom Groovy CLI commands

  • src/main/groovy − to contain supporting source files

  • src/test/groovy − contains test cases

  • src/integration-test/groovy − to contain test cases required to test application at integration level

  • src/main/scripts − to contain code generating scripts

Knowledge about grails configuration is very important for efficient grails development.

Advertisements