是否可以将 Spring Bean 暴露给 Micronaut 应用程序,并将它们与 @Autowired 一起使用,或 @Inject 它们到 Micronaut 应用程序中,并通过 Maven pom.xml 将 Spring Beans 项目作为 Maven 依赖项添加到 Micronaut 项目中?
该指南: https: //micronaut-projects.github.io/micronaut-spring/latest/guide/ 讨论“将 Micronaut Bean 暴露给 Spring 应用程序”,但反之则不然。
我想在 Micronaut 应用程序中使用的 Spring Bean 是使用 @Repository、@Component、@Service、@Configuration 公开的。
这是否可能,是否是在 Micronaut 应用程序本身中定义 Spring Bean 的先决条件,以及是否支持使用库(定义了 Spring Beans 的 JAR 文件)作为 Micronaut 应用程序的依赖项?
每当我尝试 @Autowire 或 @Inject 在与 Micronaut 应用程序不同的应用程序中定义的 Spring Bean(前者已作为 pom.xml 中的依赖项添加到其中)时,我会收到以下异常:
io.micronaut.context.exceptions.DependencyInjectionException: Failed to inject value for field [fieldName] of class: MicronautClassName_From_Where_I_have_Referrenced_the_Spring_Bean
Path Taken: Class.fieldName
at io.micronaut.context.AbstractBeanDefinition.getBeanForField(AbstractBeanDefinition.java:1462)
at …Run Code Online (Sandbox Code Playgroud)