以Kafka为独立库的spring boot cloud stream

qacovj5a  于 2021-06-04  发布在  Kafka
关注(0)|答案(1)|浏览(551)

我正在尝试在非spring应用程序中集成一个基于spring引导云流的库和kafka。
当这个库被加载到另一个spring应用程序中时,一切正常。
当我尝试用未启用spring引导的应用程序初始化应用程序上下文并获取bean时,会收到以下警告和异常:

org.springframework.core.LocalVariableTableParameterNameDiscoverer - Cannot find '.class' file for class [class com.acme.common.library.spring.service.InstrumentIdLookupServiceImpl$$EnhancerBySpringCGLIB$$59e4e4ac] - unable to determine constructor/method parameter names

org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'instrumentIdLookupServiceImpl' via constructor to bean named 'instrumentIdLookupServiceProperties'

WARN org.springframework.context.support.GenericApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.acme.common.library.spring.InstrumentIdBinding': Invocation of init method failed; nested exception is java.lang.IllegalStateException: No factory found for binding target type: org.apache.kafka.streams.kstream.KStream among registered factories: channelFactory,messageSourceFactory

No factory found for binding target type: org.apache.kafka.streams.kstream.KStream among registered factories: channelFactory,messageSourceFactory
public interface InstrumentIdBinding {
    String INSTRUMENT_IDS = "instrument-ids";

    @Input(INSTRUMENT_IDS)
    KStream<String, InstrumentIdMsg> processInstrumentId();
}
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:context="http://www.springframework.org/schema/context"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
        http://www.springframework.org/schema/beans/spring-beans.xsd
        http://www.springframework.org/schema/context
        http://www.springframework.org/schema/context/spring-context.xsd">
    <context:component-scan base-package="com.acme.common.library.spring"/>
</beans>
GenericApplicationContext ctx = new GenericApplicationContext();
final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
xmlReader.loadBeanDefinitions(new FileSystemResource("applicationContext-ext.xml"));
ctx.refresh();
InstrumentIdLookupService bean = ctx.getBean(InstrumentIdLookupService.class);

相关问题