3 Inversion of Control

    Micronaut takes inspiration from Spring, and in fact, the core developers of Micronaut are former SpringSource/Pivotal engineers now working for OCI.

    Unlike Spring which relies exclusively on runtime reflection and proxies, Micronaut uses compile time data to implement dependency injection.

    This is a similar approach taken by tools such as Google’s , which is designed primarily with Android in mind. Micronaut, on the other hand, is designed for building server-side microservices and provides many of the same tools and utilities as Spring but without using reflection or caching excessive amounts of reflection metadata.

    • Use reflection as a last resort

    • Avoid proxies

    • Provide clear, understandable error handling

    Note that the IoC part of Micronaut can be used completely independently of Micronaut itself for whatever application type you may wish to build. To do so all you need to do is configure your build appropriately to include the dependency as an annotation processor. For example with Gradle:

    Configuring Gradle

    Running the ApplicationContext

    1. MyBean myBean = context.getBean(MyBean.class); (2)
    2. // do something with your bean