spring-integration-kafka2.1配置异常找不到listener-container

youarepp 发布于 2017/02/21 11:10
阅读 421
收藏 0

在配置消费者的时候出现的异常如下,找不到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-bundle\sts-3.7.3.RELEASE\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\iamyun_api\WEB-INF\classes\spring-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-bundle\sts-3.7.3.RELEASE\workspace\.metadata\.plugins\org.eclipse.wst.server.core\tmp0\wtpwebapps\iamyun_api\WEB-INF\classes\spring-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> 

加载中
0
y
youarepp

怎么大家都没碰到过这问题吗

0
y
youarepp

spring对这块的管理太混乱,一个kafka的组件有2个版本,文档也不全,我放弃了直接用kafka-client现在一切都清净了

返回顶部
顶部