【问题标题】:SpringXD Error when deploying Stream: StringDeserializer class could not be found部署 Stream 时出现 SpringXD 错误:找不到 StringDeserializer 类
【发布时间】:2023-03-05 12:51:01
【问题描述】:

我正在配置我的自定义 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

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

    • 你说的是xd/lib,对吧?那么,我应该只更新kafka-clients jar,还是与 kafka 相关的所有内容?
    • 试试小步如何?我的意思是,让我们首先从 Kafka 开始!
    • 好的,事实上这就是我在 30 分钟前尝试过的。但是现在我遇到了新的错误。让我恢复一切,然后先更改kafka-clients jar。
    • 刚刚更新了位于xd/lib 内的kafka-clients 后,我收到了这个错误:gist.github.com/columb1a/07bb4f3da92f42bc9ad746c382091778xd/libfolder 中还有一个名为 Kafka 的文件夹。 kafka-clients还有另一个副本,我会更新它以防万一,但我不明白那个文件夹的目的是什么。
    • 我认为是给KafkaMessageBus
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 2022-06-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-02-16
      • 2017-12-18
      • 2014-11-09
      • 1970-01-01
      • 2020-11-04
      相关资源
      最近更新 更多