I have been looking for something like this.
Having this micronaut app code
@Configuration
@SpringBootApplication(exclude = {org.springframework.boot.autoconfigure.cassandra.CassandraAutoConfiguration.class,
org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration.class,
org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration.class,
org.springframework.boot.autoconfigure.orm.jpa.HibernateJpaAutoConfiguration.class})
@ComponentScan(basePackageClasses = HelloController.class)
public class Application {
public static void main(String[] args) throws Exception {
System.setProperty("akka.config", "/Users/nb38tv/workspace/hello-micronaut/src/main/resources/config/");
System.setProperty("akka.config.file", "application.conf");
ConfigurableApplicationContext springContext = ReactiveConnectorBootable.loadReactiveConnector();
ConfigurableApplicationContext context = new MicronautApplicationContext();
context.setParent(springContext);
context.start();
Micronaut.run(Application.class);
}
}
How can I merge an ApplicationContext of Spring with the one of Micronaut.
I need it since I have a library that use ApplicationContext of Spring to inject some beans.
Then in my controller I need to use it.
@Controller("/hello")
public class HelloController {
@Inject
private ReactorConnectorManager<RequestInfoDTO, String> reactorConnectorRestManagerExecutor;
@Get(produces = MediaType.TEXT_PLAIN)
public String index() {
if(reactorConnectorRestManagerExecutor == null){
return "boooo";
}
return "Hello World";
}
}
Where ReactorConnectorManager is a bean loaded in Spring context
Regards