springboot + kafka 入门实例 入门demo
版本说明
- springboot版本:2.3.3.RELEASE
- kakfa服务端版本:kafka_2.12-2.6.0.tgz
- zookeeper服务端版本:apache-zookeeper-3.6.1-bin.tar.gz
实例搭建前提条件
1,搭建好zookeeper服务,本实例zookeeper使用单机伪集群模式,
192.168.1.126:2181, 192.168.1.126:2182, 192.168.1.126:2183
2,搭建好kafka服务,本实例kafka使用单机伪集群模式,
192.168.1.126:9092, 192.168.1.126:9093, 192.168.1.126:9094
1. 导入相关依赖
<?xml version="1.0" encoding="UTF-8"?>
<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.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.3.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>springboot-kafka-demo</artifactId>
<version>1.0-SNAPSHOT</version>
<name>springboot-kafka-demo</name>
<description>springboot-kafka-demo</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId<