首先引入jar包:

<dependency>
    <groupId>org.springframework.kafka</groupId>
    <artifactId>spring-kafka</artifactId>
</dependency>

然后配置链接信息:

data:
  kafka:
    groupId: xxxxx
    bootstrapServers:  127.0.0.1:8080
    userName: kafka
    password: kafka
    topic: xxxxxxx

再编写配置类等。

启动后报错:

Description:

Parameter 0 of method loadBalancedRetryFactory in org.springframework.cloud.loadbalancer.config.BlockingLoadBalancerClientAutoConfiguration$BlockingLoadBalancerRetryConfig required a bean of type 'org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer$Factory' that could not be found.


Action:

Consider defining a bean of type 'org.springframework.cloud.client.loadbalancer.reactive.ReactiveLoadBalancer$Factory' in your configuration.

解决办法:

spring:
  cloud:
    loadbalancer:
      enabled: true

在配置文件中加入loadbalancer为true 即可解决。

更多推荐

springboot集成kafka报错解决:Consider defining a bean of type org.springframework.cloud