Search code examples
mavenapache-sparkapache-kafkakafka-producer-api

package kafka.producer does not exist after changing to kafka_2.11


I have changed to Kafka version from 2.10 to 2.11 in pom file, now I am getting below error

changes in pom from

<dependency>
<groupId>org.apache.kafka</groupId> . 
<artifactId>kafka_2.10</artifactId>
<version>0.9.0-kafka-2.0.1</version>
<scope>compile</scope>
</dependency>

to

<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka_2.11</artifactId>
<version>2.1.0-cdh6.2.0</version>
<scope>compile</scope>
</dependency>

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project

package kafka.producer does not exist


Solution

  • The scala clients (which kafka.producer was a part of) have been deprecated for years and have been removed.

    If you intend to modernize your code you should change your dependency to kafka-clients and refactor it to use the java ones.

    Be aware that there is no good "live" migration path between scala consumers (that store offsets in ZK) and the newer java consumers (that store offsets in kafka) - see KIP-125 for the details