spring-bootmicronaut

Using Micronaut Beans in Spring Application


Our application is Spring based and we are planning to include Micronaut also within our application. So, basically, we are looking for a way to have both Micronaut and Spring in our application. The problem currently is that Micronaut beans are not getting exposed to the Spring application context.

The problem we are facing currently is that Micronaut beans are not getting exposed to the Spring application context at runtime. We used the MicronautBeanProcessor but it is not working. We are taking reference from this article: Exposing Micronaut Bean in Spring Application

Here is the code snippet for MicronautBeanProcessor:

@Bean
public static MicronautBeanProcessor httpClientMicronautBeanProcessor() {
        return new MicronautBeanProcessor(Controller.class, Post.class, Get.class, Singleton.class, Singleton.class);
}

Solution

  • This has been solved. If your application is Spring boot based (my case) you can refer Using the Micronaut Spring Boot Starter.

    Also, a very important thing to keep in mind is there is no support for writing Micronaut controllers(Rest endpoints) or anything web tier at the moment(micronaut-spring-boot-starter version 5.4.0). So, if you plan to use both Spring boot and Micronaut together in your application, the controllers will still have to use Spring-based annotations.