spring-integration-kafka2.1配置异常找不到listener-container
在配置消费者的时候出现的异常如下,找不到container1这个参数配置,在spring-integration-kafka.xsd找了发现listener-container指向的是org.springframework.integration.kafka.listener.KafkaMessageListenerContainer,但是在spring-integration-kafka里面没有发现这个类,不知道大家有没有碰到过这个问题,又是如何解决的
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'kafkaListener': Cannot resolve reference to bean 'container1' while setting constructor argument; nested exception is org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'container1' defined in file [C:sts-bundlests-3.7.3.RELEASEworkspace.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsiamyun_apiWEB-INFclassesspring-integration-kafka-consumer.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.kafka.listener.config.ContainerProperties]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
Related cause: org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'container1' defined in file [C:sts-bundlests-3.7.3.RELEASEworkspace.metadata.pluginsorg.eclipse.wst.server.coretmp0wtpwebappsiamyun_apiWEB-INFclassesspring-integration-kafka-consumer.xml]: Unsatisfied dependency expressed through constructor argument with index 1 of type [org.springframework.kafka.listener.config.ContainerProperties]: Ambiguous constructor argument types - did you specify the correct bean references as constructor arguments?
配置文件如下:
<?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:int-kafka="http://www.springframework.org/schema/integration/kafka"
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/integration/kafka
http://www.springframework.org/schema/integration/kafka/spring-integration-kafka-2.1.xsd
http://www.springframework.org/schema/integration
http://www.springframework.org/schema/integration/spring-integration-4.3.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.2.xsd">
<bean id="container1" class="org.springframework.integration.kafka.listener.KafkaMessageListenerContainer">
<constructor-arg>
<bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
<constructor-arg>
<map>
<entry key="bootstrap.servers" value="localhost:9092" />
<entry key="key.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer"></entry>
<entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer"></entry>
</map>
</constructor-arg>
</bean>
</constructor-arg>
<constructor-arg name="topics" value="test" />
</bean>
<int-kafka:message-driven-channel-adapter
id="kafkaListener"
listener-container="container1"
auto-startup="false"
phase="100"
send-timeout="5000"
channel="nullChannel"
error-channel="errorChannel" />
</beans>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
spring对这块的管理太混乱,一个kafka的组件有2个版本,文档也不全,我放弃了直接用kafka-client现在一切都清净了