SpringXD无法找到部署Stream:StringDeserializer类时出错

时间:2017-04-10 19:12:20

标签: java spring spring-integration spring-xd spring-kafka

我正在配置我的自定义kafka源,并且我收到与value.deserializer kafka属性相关的错误。

这是我的配置:

<!--Consumer -->
<bean id="container1"
    class="org.springframework.kafka.listener.KafkaMessageListenerContainer">
    <constructor-arg>
        <bean class="org.springframework.kafka.core.DefaultKafkaConsumerFactory">
            <constructor-arg>
                <map>
                    <entry key="bootstrap.servers" value="localhost:9092" />
                    <entry key="enable.auto.commit" value="false" />
                    <entry key="auto.commit.interval.ms" value="100" />
                    <entry key="session.timeout.ms" value="15000" />
                    <entry key="group.id" value="bridge-stream-testing" />
                    <entry key="key.deserializer" value="org.apache.kafka.common.serialization.IntegerDeserializer" />
                    <entry key="value.deserializer" value="org.apache.kafka.common.serialization.StringDeserializer" />
                </map>
            </constructor-arg>
        </bean>
    </constructor-arg>

我确实看到了org.apache.kafka.common.serialization.StringDeserializer类(我可以单击类名,它会将我带到jar文件中。

以防这是我的pom文件中的内容:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.xd</groupId>
        <artifactId>spring-xd-module-parent</artifactId>
        <version>1.3.2.RELEASE</version>
    </parent>
    <groupId>ejemplos.spring</groupId>
    <artifactId>kafka-source-latest-api</artifactId>
    <version>0.0.1-SNAPSHOT</version>

    <dependencies>
        <dependency>
            <groupId>org.springframework.integration</groupId>
            <artifactId>spring-integration-kafka</artifactId>
            <version>2.1.0.RELEASE</version>
        </dependency>

        <dependency>
            <groupId>org.apache.kafka</groupId>
            <artifactId>kafka-clients</artifactId>
            <version>0.10.0.1</version>
            <scope>compile</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.kafka</groupId>
            <artifactId>spring-kafka</artifactId>
            <version>1.1.0.RELEASE</version>
        </dependency>


    </dependencies>

    <repositories>
        <repository>
            <id>pentaho-releases</id>
            <url>http://repository.pentaho.org/artifactory/repo/</url>
        </repository>
    </repositories>
</project>

这些是我得到的日志:https://gist.github.com/columb1a/2833f1ac751436df1caa730ce1a0eb37

2 个答案:

答案 0 :(得分:1)

尝试将kafka-clients jar放入共享/lib而不是模块类路径。我只是猜测,但看起来该类试图由Thread.currentThread().getContextClassLoader();加载而不是特定于模块。

答案 1 :(得分:0)

我解决了我的问题,如下所示:将kafka-clients PLUS 替换为我的pom文件中的provided范围已添加kafka-clients范围后,我的消费者工作正常(到目前为止)。