DEV Community


Wiring Micronaut beans in Grails Services

erichelgeson profile image Eric Helgeson ・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.

Discussion (0)

Editor guide