The import org.springframework.kafka cannot be resolved with gradle

934 Views Asked by At

I use a 'kafka-clients' dependency and It ran yesterday. but it is not running because it can't find a KafkaListener Class. These are a part of source that calls the KafkaListener class and a part of build.gradle file that are relation with KafkaListener.

I try to gradlew clean build before executing the project.

Environment: OS : Windows springboot : 2.7.9 spring : 5.3.25 java : 11

KafkaController.java

import org.springframework.kafka.annotation.KafkaListener;
...

    @KafkaListener(topics = topicName, groupId = groupId)
    public void listen(String message) {

...

    }

build.gradle

// kafka
implementation 'org.apache.kafka:kafka-clients:3.0.0'

gradlew clean build on Windows OS

1

There are 1 best solutions below

0
Juan Daniel Ornella On

You need to add this dependency

implementation 'org.springframework.kafka:spring-kafka:3.0.0'