Skip to content
loading...

Wiring Micronaut beans in Grails Services

erichelgeson profile image Eric Helgeson twitter logo github logo ・1 min read

Micronaut beans in Grails 4 are wired by type - not the default Grails users are used to using - wire by name.

For example if we have a micronaut-http-client bean named MyRestClient under src/main/groovy/<package>/MyRestClient.groovy and we want to wire it into the Grails service SomeService we must supply the type:

class SomeService {
    // ❌ wont work, as Grails will look for a bean name that wont exist.
    // def myRestClient

    // ✅ Works!
    MyRestClient myRestClient
}

Tested on Grails 4.0.2.

twitter logo DISCUSS
Discussion
markdown guide
Classic DEV Post from Aug 4 '19

You're not worth hiring unless...

Eric Helgeson profile image