Spring启动应用程序无法注入CDI bean。

时间:2018-05-07 12:31:27

标签: spring spring-boot spring-batch cdi

我正在尝试在springboot应用程序中使用CDI创建的bean。 Spring启动项目可以访问所需的基于CDI的DI类,但@Inject无法将CDI bean注入Spring启动项目。

注意:我试图在我的spring上下文文件中添加以下行以解决此问题:

<bean class="org.cdisource.springintegration.CdiBeanFactoryPostProcessor" />

但我得到的错误是:

Caused by: java.lang.ClassNotFoundException: org.cdisource.springintegration.CdiBeanFactoryPostProcessor
    at java.net.URLClassLoader.findClass(URLClassLoader.java:607) ~[?:1.8.0-internal]
    at java.lang.ClassLoader.loadClassHelper(ClassLoader.java:846) ~[?:1.8.0-internal]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:825) ~[?:1.8.0-internal]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:325) ~[?:1.8.0-internal]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:805) ~[?:1.8.0-internal]
    at org.springframework.util.ClassUtils.forName(ClassUtils.java:274) ~[spring-core-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanDefinition.resolveBeanClass(AbstractBeanDefinition.java:437) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.doResolveBeanClass(AbstractBeanFactory.java:1428) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.resolveBeanClass(AbstractBeanFactory.java:1372) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.determineTargetType(AbstractAutowireCapableBeanFactory.java:666) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.predictBeanType(AbstractAutowireCapableBeanFactory.java:633) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.AbstractBeanFactory.isFactoryBean(AbstractBeanFactory.java:1489) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doGetBeanNamesForType(DefaultListableBeanFactory.java:420) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.getBeanNamesForType(DefaultListableBeanFactory.java:390) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.BeanFactoryUtils.beanNamesForTypeIncludingAncestors(BeanFactoryUtils.java:208) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.findAutowireCandidates(DefaultListableBeanFactory.java:1276) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.doResolveDependency(DefaultListableBeanFactory.java:1101) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.support.DefaultListableBeanFactory.resolveDependency(DefaultListableBeanFactory.java:1065) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    at org.springframework.beans.factory.annotation.AutowiredAnnotationBeanPostProcessor$AutowiredFieldElement.inject(AutowiredAnnotationBeanPostProcessor.java:584) ~[spring-beans-5.0.5.RELEASE.jar:5.0.5.RELEASE]
    ... 19 more

&#34; org.cdisource.springintegration.CdiBeanFactoryPostProcessor&#34;所需的依赖关系。在maven存储库中找不到。

如果有任何机构有关于此CDI和弹簧集成的任何解决方案,请分享这个概念。

0 个答案:

没有答案