How to disable all Kafka related auto configuration from yaml/properties file in spring-boot-2 without removing dependencies?
J

1

6

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,

Joplin answered 20/8, 2019 at 8:40 Comment(1)
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 workEatton
S
3

Instead of @EnableAutoConfiguration(exclude = KafkaAutoConfiguration.class)

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

Shawannashawl answered 7/3, 2020 at 3:52 Comment(1)
How to exclude kafkaautoconfiguration for specific profile? When spring.profile.active=QA then I want to exclude Kafka auto configuration.Discotheque

© 2022 - 2025 — McMap. All rights reserved.