Goodbye Grails, Hello Micronaut #2: Configuration
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
- Multiproject
- Configuration
- Static Compilation
- Datasets
- Marshalling
- Domain Classes
- Services
- Controllers
- Micronaut Application
- Micronaut Data