以Kafka为独立库的spring boot cloud stream

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

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

  1. 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
  2. org.springframework.beans.factory.support.DefaultListableBeanFactory - Autowiring by type from bean name 'instrumentIdLookupServiceImpl' via constructor to bean named 'instrumentIdLookupServiceProperties'
  3. 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
  4. No factory found for binding target type: org.apache.kafka.streams.kstream.KStream among registered factories: channelFactory,messageSourceFactory
  1. public interface InstrumentIdBinding {
  2. String INSTRUMENT_IDS = "instrument-ids";
  3. @Input(INSTRUMENT_IDS)
  4. KStream<String, InstrumentIdMsg> processInstrumentId();
  5. }
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:context="http://www.springframework.org/schema/context"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans.xsd
  7. http://www.springframework.org/schema/context
  8. http://www.springframework.org/schema/context/spring-context.xsd">
  9. <context:component-scan base-package="com.acme.common.library.spring"/>
  10. </beans>
  1. GenericApplicationContext ctx = new GenericApplicationContext();
  2. final XmlBeanDefinitionReader xmlReader = new XmlBeanDefinitionReader(ctx);
  3. xmlReader.loadBeanDefinitions(new FileSystemResource("applicationContext-ext.xml"));
  4. ctx.refresh();
  5. InstrumentIdLookupService bean = ctx.getBean(InstrumentIdLookupService.class);
cwtwac6a

cwtwac6a1#

Spring Cloud流需要春靴。

相关问题