Last updated by esumerfd 10 months ago
The Grails console
Grails ships with an extended version of the regular Groovy console. To run the console simply type the following command from the root of a Grails project:grails console
The Grails interactive shell
In addition to the console there is the interactive shell. It works similar to the console but with a text UI only. To run the shell simply type the following command from the root of a Grails project:grails shell
General usage
Both console and shell are useful for working interactively with your Grails application:- find domain objects with the help of dynamic finder methods
- call mutator methods on domain objects once you have a reference to them
- save() or delete() domain objects like you would otherwise do in a controller
- … _more to come here_
class Book {
String title
String author
String description
}groovy:000> new Book(title:'Grails in Action', author:'Glen Smith', groovy:001> description: 'Manning Early Access').save() ===> Book : 1 groovy:000> new Book(title:'The definitve Guide to Grails', author:'Graeme Rocher', groovy:001> description: 'First book by the Project Lead of Grails').save() ===> Book : 2 groovy:000> Book.findAllByTitleLike('Grails%').title ===> [Grails in Action] groovy:000> Book.findAllByTitleLike('%Grails%').title ===> [Grails in Action, The definitve Guide to Grails] groovy:000> Book.findAllByAuthorLike('G%').author ===> [Glen Smith, Graeme Rocher]
.... more to come here (example with associations)
Packaging a WAR
To package a WAR file for deployment onto an application server you can do:grails war
grails test war // for test enviroment grails dev war // for development environment grails prod war // for production
grails -Dgrails.env=blah war
Development
If you are a developer working with the Grails application you may be interested in how to debug it remotely. Starting Grails in this manner will make it listen on por 5005 so that you can connect your favorite remote debugger to it.grails-debug run-app



