英文:
My FlinkKafkaProducer011 needs fewer arguments than is supposed to
问题
I’m having difficulties with FlinkKafkaConnector.
虽然我已经导入了org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
,但我收到了以下错误消息。
构造函数FlinkKafkaProducer011有太多参数
根据此网站,参数是正确的。然而,我的IntelliJ显示如下定义。
public FlinkKafkaProducer011() {
}
有人知道如何修复吗?
更新
这是IDE的定义。
public class FlinkKafkaProducer011 {
public FlinkKafkaProducer011() {
}
public static class NextTransactionalIdHint extends org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint {
public NextTransactionalIdHint() {
}
}
public static class TransactionStateSerializer {
public TransactionStateSerializer() {
}
public static final class TransactionStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionState> {
public TransactionStateSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.TransactionStateSerializer::new);
}
}
}
public static class ContextStateSerializer {
public ContextStateSerializer() {
}
public static final class ContextStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionContext> {
public ContextStateSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.ContextStateSerializer::new);
}
}
}
public static class NextTransactionalIdHintSerializer {
public NextTransactionalIdHintSerializer() {
}
public static final class NextTransactionalIdHintSerializerSnapshot extends SimpleTypeSerializerSnapshot<org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint> {
public NextTransactionalIdHintSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHintSerializer::new);
}
}
}
}
英文:
I’m having difficulties with FlinkKafkaConnector.
Although I have imported the org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
, I got the following error.
Too many arguments for constructor FlinkKafkaProducer011
According to this site, the arguments are correct. However, my IntelliJ shows this definition.
public FlinkKafkaProducer011() {
}
Does anyone know how to fix it?
UPDATE
Here is the IDE definition.
public class FlinkKafkaProducer011 {
public FlinkKafkaProducer011() {
}
public static class NextTransactionalIdHint extends org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint {
public NextTransactionalIdHint() {
}
}
public static class TransactionStateSerializer {
public TransactionStateSerializer() {
}
public static final class TransactionStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionState> {
public TransactionStateSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.TransactionStateSerializer::new);
}
}
}
public static class ContextStateSerializer {
public ContextStateSerializer() {
}
public static final class ContextStateSerializerSnapshot extends SimpleTypeSerializerSnapshot<KafkaTransactionContext> {
public ContextStateSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.ContextStateSerializer::new);
}
}
}
public static class NextTransactionalIdHintSerializer {
public NextTransactionalIdHintSerializer() {
}
public static final class NextTransactionalIdHintSerializerSnapshot extends SimpleTypeSerializerSnapshot<org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHint> {
public NextTransactionalIdHintSerializerSnapshot() {
super(org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer.NextTransactionalIdHintSerializer::new);
}
}
}
}
答案1
得分: 2
请问您使用的是flink-connector-kafka
的哪个版本?
根据我所看到的情况,您使用的org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
只是flink-connector-kafka_2.11
JAR包的兼容性类,正确的生产者应该是org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer
。
据我了解,这里的Java文档适用于flink-connector-kafka-0.11_2.11
版本的org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
生产者。
因此,我建议要么切换到org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer
,要么将依赖项更改为flink-connector-kafka-0.11_2.11
JAR包。
英文:
Could you please specify what flink-connector-kafka
version you use ?
From what I can see, the org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
you have used is just a compatibility class from flink-connector-kafka_2.11
jar and the right producer to use is org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer
.
As far as I understand, the javadoc https://ci.apache.org/projects/flink/flink-docs-release-1.4/api/java/org/apache/flink/streaming/connectors/kafka/FlinkKafkaProducer011.html is relevant for org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer011
producer from flink-connector-kafka-0.11_2.11
artifact.
So, I would suggest to either switch to org.apache.flink.streaming.connectors.kafka.FlinkKafkaProducer
or change dependency to flink-connector-kafka-0.11_2.11
jar.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论