Last updated by 5 years ago

Page: Console Plugin, Version:14



  • in command prompt, under your project directory
    grails install-plugin console
  • access the console at ${contextPath}/console


  • Type any Groovy command in the console text area, then press "Execute"
  • The following implicit variables are available:
    • application - grailsApplication instance, e.g.
      println application.getFlatConfig()
    • context - Spring ApplicationContext, e.g.
      import groovy.sql.Sql
      def dataSource = context.getBean('dataSource')
      def sql = Sql.newInstance(dataSource)
          sql.eachRow("select * from information_schema.system_tables", {
          println "${it.TABLE_NAME}"
    • session - the current HTTP session
      session.getAttributeNames().each{ attr ->
        println attr.padRight(40) + session.getAttribute(attr)
    • request - the current HTTP request, e.g.
      def params = ['requestURI', 'requestURL', 'forwardURI']
              println it + "t" + request."$it"
    • shell - the Groovy Shell instance
      println shell.'application'
      println application
      println shell.'application' == application
  • defining variables
    • The console instance is maintained in session scope.
    • similar to normal Groovy Shell, you don't need to use "def" to declare a variable, e.g. the following won't work
      def foo = "bar"
      println foo
    • but you can use
      foo = "bar"
      println foo
  • Result Area
    • The result area display the output of "println" and the return value of the last line of execute (in blue).


  • This plugin is tested with Grails 1.1 RC1


Author Siegfried Puchbauer, Mingfai Ma