5

I have create a spring-boot-2 gradle project, also in build.gradle file i have added Kafka related dependency which given below.

dependencies {
    implementation 'org.springframework.cloud:spring-cloud-starter-zipkin'
    compile 'org.springframework.cloud:spring-cloud-starter-bus-kafka'
}

now i want to disable all Kafka related Auto configuration from application.yaml file for that i have tried given below code in my yaml file.

spring:
  autoconfigure:
      exclude:
        - org.springframework.boot.autoconfigure.kafka.KafkaAutoConfiguration

After implementing above things still the Kafka got Auto-configured and start integration of Kafka with the application.

Also i have tried below code but this is also not working for me.

@SpringBootApplication
@EnableAutoConfiguration(exclude = KafkaAutoConfiguration.class)
public class ApiGatewayApplication {

    public static void main(String[] args) {
        SpringApplication.run(ApiGatewayApplication.class, args);
    }

}

Now please can any one help me out, how can i disable all auto configuration related to kafka from yaml/properties file ?

Thanks,

OneCricketeer
  • 179,855
  • 19
  • 132
  • 245
ajay panchal
  • 145
  • 1
  • 11
  • For me it worked in application.yaml as you have tried. But with spring-boot 3, didn't try with spring-boot 2 but I think it still should work – baraber Aug 04 '23 at 18:38

1 Answers1

2

Instead of @EnableAutoConfiguration(exclude = KafkaAutoConfiguration.class)

You should do @SpringBootApplication(exclude = KafkaAutoConfiguration.class)

Giovane
  • 1,421
  • 1
  • 15
  • 25
  • 1
    How to exclude kafkaautoconfiguration for specific profile? When spring.profile.active=QA then I want to exclude Kafka auto configuration. – StackOverFlow Dec 08 '22 at 12:01