Maven Repository
Kafka
Programming
Software Development
Apache Kafka

where can I find maven repository for kafka?

Master System Design with Codemia

Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.

Introduction

For normal Apache Kafka Java dependencies, you usually do not need a special repository at all because the artifacts are published to Maven Central. The more important question is which Kafka artifact you actually need, since Kafka provides different modules for clients, streams, connectors, and older Scala-based components.

The Common Artifact: kafka-clients

If you are writing a producer or consumer in Java, the dependency most people want is org.apache.kafka:kafka-clients.

A basic Maven example:

xml
1<dependencies>
2  <dependency>
3    <groupId>org.apache.kafka</groupId>
4    <artifactId>kafka-clients</artifactId>
5    <version>YOUR_KAFKA_VERSION</version>
6  </dependency>
7</dependencies>

For most projects, Maven Central is enough. You do not need to add a custom repository block just to get this dependency.

Kafka Streams Uses a Different Artifact

If you are building a Kafka Streams application, use the streams artifact instead.

xml
1<dependencies>
2  <dependency>
3    <groupId>org.apache.kafka</groupId>
4    <artifactId>kafka-streams</artifactId>
5    <version>YOUR_KAFKA_VERSION</version>
6  </dependency>
7</dependencies>

The repository is still usually Maven Central. The difference is the artifact name, not the repository location.

A Clean pom.xml Pattern

A useful habit is to define the Kafka version once in Maven properties.

xml
1<properties>
2  <kafka.version>YOUR_KAFKA_VERSION</kafka.version>
3</properties>
4
5<dependencies>
6  <dependency>
7    <groupId>org.apache.kafka</groupId>
8    <artifactId>kafka-clients</artifactId>
9    <version>${kafka.version}</version>
10  </dependency>
11</dependencies>

That keeps upgrades simpler because you change the version in one place.

Producer Example Using the Dependency

Once the dependency is available, a small producer looks like this:

java
1import java.util.Properties;
2import org.apache.kafka.clients.producer.KafkaProducer;
3import org.apache.kafka.clients.producer.ProducerRecord;
4
5public class ProducerExample {
6    public static void main(String[] args) {
7        Properties props = new Properties();
8        props.put("bootstrap.servers", "localhost:9092");
9        props.put("key.serializer", "org.apache.kafka.common.serialization.StringSerializer");
10        props.put("value.serializer", "org.apache.kafka.common.serialization.StringSerializer");
11
12        try (KafkaProducer<String, String> producer = new KafkaProducer<>(props)) {
13            producer.send(new ProducerRecord<>("demo-topic", "key", "value"));
14            producer.flush();
15        }
16    }
17}

If this compiles, your Maven dependency resolution is doing its job.

Consumer Example

A basic consumer depends on the same kafka-clients artifact.

java
1import java.time.Duration;
2import java.util.Collections;
3import java.util.Properties;
4import org.apache.kafka.clients.consumer.ConsumerConfig;
5import org.apache.kafka.clients.consumer.ConsumerRecord;
6import org.apache.kafka.clients.consumer.KafkaConsumer;
7
8public class ConsumerExample {
9    public static void main(String[] args) {
10        Properties props = new Properties();
11        props.put("bootstrap.servers", "localhost:9092");
12        props.put(ConsumerConfig.GROUP_ID_CONFIG, "demo-group");
13        props.put("key.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
14        props.put("value.deserializer", "org.apache.kafka.common.serialization.StringDeserializer");
15        props.put(ConsumerConfig.AUTO_OFFSET_RESET_CONFIG, "earliest");
16
17        try (KafkaConsumer<String, String> consumer = new KafkaConsumer<>(props)) {
18            consumer.subscribe(Collections.singletonList("demo-topic"));
19            var records = consumer.poll(Duration.ofSeconds(1));
20            for (ConsumerRecord<String, String> record : records) {
21                System.out.println(record.value());
22            }
23        }
24    }
25}

Again, the key dependency is still kafka-clients.

When You Might Need Another Repository

For plain Apache Kafka client libraries, Maven Central is the normal source. You might need an additional repository only when:

  • you depend on vendor-specific artifacts
  • you use Confluent platform components not mirrored in the same way
  • you are consuming snapshots or unusual internal builds

That is a different situation from standard Apache Kafka usage.

Watch Out for the Old Scala Artifacts

Older tutorials sometimes reference artifacts such as kafka_2.12 or other Scala-version-suffixed modules. Those exist for specific Kafka modules, but many Java applications only need kafka-clients and should not pull in more than necessary.

If your project is a regular Java producer or consumer, start small and add extra Kafka modules only when the use case really demands them.

Common Pitfalls

The most common mistake is searching for a special Kafka Maven repository when the real issue is simply using the wrong artifact ID. For plain Java producers and consumers, kafka-clients is usually the correct dependency.

Another issue is copying a very old version number from a blog post. Choose a version intentionally rather than inheriting one from stale documentation.

Developers also sometimes add extra repositories unnecessarily. That complicates builds and can introduce dependency-resolution surprises when Maven Central would have been enough.

Finally, do not confuse the Kafka broker version with your client dependency strategy. Clients are versioned artifacts in Maven; broker connectivity is a separate runtime concern.

Summary

  • Standard Apache Kafka Maven artifacts are usually available from Maven Central.
  • For normal Java producers and consumers, the key dependency is org.apache.kafka:kafka-clients.
  • Use kafka-streams only when you are building a Kafka Streams application.
  • Add custom repositories only when you truly depend on nonstandard vendor or snapshot artifacts.
  • The main failure mode is often choosing the wrong artifact, not failing to find the right repository.

Course illustration
Course illustration

All Rights Reserved.