Goodbye Grails, Hello Micronaut #2: Configuration

Vladimír Oraný
Stories by Agorapulse
2 min readAug 3, 2021

This is the second post in a series that will guide you through the migration from Grails to Micronaut. This guide requires your application to be based on Grails 4.x or later.

Let's start with a simple warmup session to migrate the way how the application configuration is accessed.

Grails allows you to access the configuration from the GrailsApplication object or using the static methods of theHolders class.

Grails 4.x is already based on Micronaut so you can take advantage of all Micronaut's features, including configuration properties objects. You can create a simple object to bind the configuration values:

This object can be injected into any Grails service. You need to annotate the field with @Inject annotation as automatic binding no longer works for Micronaut beans.

As a bonus, you can add additional validation to the configuration class and your service is now fully compile-static-ready.

In the next step, you will learn how to add a static compilation globally into your Grails project.

Table of Contents

  1. Multiproject
  2. Configuration
  3. Static Compilation
  4. Datasets
  5. Marshalling
  6. Domain Classes
  7. Services
  8. Controllers
  9. Micronaut Application
  10. Micronaut Data

Sources & Discussion

--

--