0
点赞
收藏
分享

微信扫一扫

MyBatisPlus实现增删改查

爱写作的小土豆 2024-07-24 阅读 27

在配置中添加json序列化器

spring:
 application:
   name: spring-boot-kafka-base
 kafka:
   bootstrap-servers: 192.168.225.128:9092
   # 配置生产者序列化
   producer:
     value-serializer: org.springframework.kafka.support.serializer.JsonSerializer
   # 配置默认的topic
   template:
     default-topic: test

发送对象消息

public void sendEvent5(){
   kafkaTemplate.sendDefault(null,System.currentTimeMillis(),"k3",User.builder()
                   .age(10)
                   .name("小王")
                   .build());
}
举报

相关推荐

0 条评论