(Quick Reference)

1 Introduction

Version: 3.3.0

1 Introduction

Many modern web frameworks in the Java space are more complicated than needed and don’t embrace the Don’t Repeat Yourself (DRY) principles.

Dynamic frameworks like Rails and Django helped pave the way to a more modern way of thinking about web applications. Grails builds on these concepts and dramatically reduces the complexity of building web applications on the Java platform. What makes it different, however, is that it does so by building on already established Java technologies like Spring and Hibernate.

Grails is a full stack framework and attempts to solve as many pieces of the web development puzzle through the core technology and its associated plugins. Included out the box are things like:

All of these are made easy to use through the power of the Groovy language and the extensive use of Domain Specific Languages (DSLs)

This documentation will take you through getting started with Grails and building web applications with the Grails framework.

In addition to this documentation there are comprehensive guides that walk you through various aspects of the technology.

Finally, Grails is far more than just a web framework and is made up of various sub-projects. The following table summarizes some other key projects in the eco-system with links to documentation.

Table 1. Grails Ecosystem Projects
Project Description

GORM for Hibernate

An Object Mapping implementation for SQL databases

GORM for MongoDB

An Object Mapping implementation for the MongoDB Document Database

GORM for Neo4j

An Object Mapping implementation for Neo4j Graph Database

JSON Views

A View technology for rendering JSON on the server side

Groovy Server Pages

A View technology for rendering HTML and other markup on the server

Async Framework

Asynchronous programming abstraction with support for RxJava, GPars and more

1.1 What's new in Grails 3.3?

This section covers all the new features introduced in Grails 3.3.

1.1.1 GORM 6.1

Grails 3.3 comes with GORM 6.1, which includes the following new features:

  • Multi-Tenancy AST Transforms

  • Rewritten @Transactional and @Rollback transformations

  • Common Services like TenantService and TransactionService

  • Data Services Concept - Implement interfaces automatically!

  • Bean Validation API Support

  • JPA Annotation Support

  • Package Scanning and Easy Unit Testing

  • Neo4j Bolt 1.2 Driver Support

  • MongoDB 3.4 Driver Support

There are so many new features and novelties in GORM that we had to write its own independent What’s New Guide!

1.1.2 New Events API

The Grails Async Framework has been extracted from Grails and moved to a separate project.

This allows the Async support to evolve independent of the framework itself in a fast moving and evolving area.

In order to support multiple different asynchronous and reactive frameworks Grails 3.3 has been decoupled from Reactor 2.x and an abstract EventBus notation added.

The EventBus interface provides the foundation and multiple implementations including GPars and RxJava.

A new set of annotations usable in services classes and regular Spring beans can be leveraged to publish and consume events:

  • Publisher - A transformation that transforms a method ensuring the return value is published as an event

  • Subscriber - A transformation that transforms a method to listen for an event.

For more information see the new documentation.

1.1.3 New Testing Framework

Grails 3.3 includes a new Trait-based testing framework that replaces the existing @TestMixin based framework with a simpler implementation that is easier to debug, provides better code completion and is easier to extend.

An example hello world test can be seen below:

import spock.lang.Specification
import grails.testing.web.controllers.ControllerUnitTest

class HelloControllerTests extends Specification implements ControllerUnitTest<HelloController> {

    void "Test message action"() {
        when:"The message action is invoked"

        then:"Hello is returned"
        response.text == 'Hello'

1.1.4 JSON Views 1.2

Version 1.2 of the JSON Views plugin is included with Grails 3.3’s "rest-api" profile and includes a number of new features. Below are some of the highlights:

  • Support for the JSON API specification

  • Ability to register custom converters

  • Multiple configuration options for date formatting, unicode escaping, etc

1.1.5 Updated Dependencies

Grails 3.3 ships with the following dependency upgrades:

  • Hibernate 5.1.5 (now the default version of Hibernate for new applications)

  • Spring Framework 4.3.9

  • Spring Boot 1.5.4

  • Gradle 3.5 (Grails 3.3 is also compatible with Gradle 4.x)

  • Spock 1.1

1.1.6 Other Novelties

Cache Plugin Rewritten

The Cache Plugin has been rewritten and no loader use proxies which improves startup time and performance. The plugin is also now Multi-Tenant aware, ensuring that cached data is not seen by other tenants.

Converters plugin now Separate

With JSON Views now being the recommended way to render JSON. The converters plugin has been split out from core into a separate project.