O'Reilly logo
live online training icon Live Online training

Grails 3 application development

From RESTful web services to web applications

Ken Kousen

The original version of Grails was designed to make it easy to build traditional web applications based on Hibernate and the Spring Framework. The current version of Grails has evolved far beyond that, with profiles that make it easy to build REST-based microservices, employ JavaScript framework-based frontends, use a wide variety of NoSQL databases, and more. In addition, Grails is now based on Spring Boot, allowing you to leverage any knowledge you've gained in that framework as well.

Modern Grails development brings the power of Groovy to elegantly combine state-of-the-art Java frameworks. Over two four-hour sessions, Ken Kousen demonstrates the new development capabilities of Grails 3 and teaches you to build applications that have domain models, controllers, transactional services, and the powerful Grails object-relational mapping capabilities under the hood.

What you'll learn-and how you can apply it

By the end of this live online course, you’ll understand:

  • How the object-relational mapping capabilities in Grails simplify database access
  • How to take advantage of the Gradle build system in Grails
  • How Grails 3 brings the power of Groovy to Java- and Spring-based frameworks

And you’ll be able to:

  • Build applications that have domain models, controllers, and transactional services
  • Build REST-based microservices
  • Employ JavaScript framework-based frontends
  • Discuss a wide variety of NoSQL databases
  • Leverage your Spring Boot knowledge using Grails 3

This training course is for you because...

  • You're an experienced Java developer who is interested in the latest Grails features.
  • You're a team member or leader who needs to build and support Grails applications.
  • You want to know how to build applications with domain models, controllers, and transactional services in Grails.
  • You want to build and deploy RESTful web services or add powerful capabilities to an underlying Spring Boot system.


  • A basic understanding of an existing Java web framework (useful but not required)

Required materials and setup:

  • A machine with Java 1.7 or above (Java 1.8 preferred; install a full SDK rather than just the JRE) and Grails installed

Recommended preparation:

Starting a Grails 3 Project (video)

Understanding the Grails 3 Domain Model (video)

Working with Grails 3 Controllers and Services (video)

About your instructor


The timeframes are only estimates and may vary according to how the class is progressing

Day 1

Modern development in Grails 3 (30 minutes)

  • Lecture: Installation options; features of the latest major version; using SDK Manager; the ZIP install
  • Hands-on exercise: Confirm the Grails installation

Basic Groovy (40 minutes)

  • Lecture: Data types and classes; strings and other basic classes; collections; closures and delegates; examples
  • Hands-on exercise: Use strings, collections, and closures

Break (10 minutes)

Requests and responses in Grails (40 minutes)

  • Lecture: Creating a new Grails application; adding a controller; sending HTTP requests; rendering a response; redirecting to another resource; forwarding to a destination; content negotiation with respond
  • Hands-on exercise: Create a basic controller with render, redirect, and return

Break (10 minutes)

Basic domain models (40 minutes)

  • Lecture: Creating a domain class; adding attributes; enforcing constraints; transient properties; basic relationships
  • Hands-on exercise: Add domain classes to a new application

Break (10 minutes)

GORM capabilities (30 minutes)

  • Lecture: Adding classes to the domain model; one-to-many and many-to-many relationships; logging SQL; unidirectional and bidirectional relationships; saving and updating domain objects
  • Hands-on exercise: Complete the domain model

Beyond GORM basics (30 minutes)

  • Lecture: Dynamic finders; using the Hibernate criteria builder; adding where queries, both connected and detached; eager and lazy fetching of relationships; the Hibernate session
  • Hands-on exercise: Query the domain model

Day 2

Testing (40 minutes)

  • Lecture: Testing controllers; mocking GORM methods; transactional tests; the Spock testing framework; integration tests and dependency injection; functional tests with Geb
  • Hands-on exercise: Test constraints and controllers

Break (10 minutes)

Transactional services (30 minutes)

  • Lecture: Dependency injection with Spring; customizing transactional behavior; moving transactional behavior from controllers to services; options for propagation and isolation levels
  • Hands-on exercise: Implement selective execution

Advanced database capabilities (30 minutes)

  • Lecture: The DB console and the console plugin; multiple datasources; working with MongoDB; issues with Neo4j and Redis; other NoSQL capabilities
  • Hands-on exercise: Utilize GORM and the console plugin

Break (10 minutes)

Configuration and customization (35 minutes)

  • Lecture: Configuring logging; Grails environments from dev to test to production; using the bootstrap; adding dependencies and drivers in the Gradle build; YML and Spring Boot; URL mappings
  • Hands-on exercise: Log SQL to files

The view layer (40 minutes)

  • Lecture: The traditional GSP layer; JSON views for RESTful web services; command objects; interceptors
  • Hands-on exercise: Explore views for web apps and REST

Break (10 minutes)

Profiles and REST (25 minutes)

  • Lecture: Building a RESTful web service; using @RestController; content negotiation; generating a deployable JAR with an embedded server; packaging and deployment
  • Hands-on exercise: Deploy a production application

Further work, wrap-up, and Q&A (10 minutes)