springboot + kafka 入门实例 入门demo

本文档介绍了如何使用SpringBoot 2.3.3.RELEASE与Kafka 2.6.0进行集成,包括环境准备、依赖导入、YAML配置、消息实体类、Kafka配置、消费者监听类及测试类的详细步骤,最后展示了实例运行结果。
摘要由CSDN通过智能技术生成

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<
  • 3
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

无尽光芒oy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值