title: Spring boot: excluding some autoconfigured beans
body: <p>I have a Spring boot project that uses spring-kafka. In this project I've built some event driven components that wrap spring-kafka beans (namely KafkaTemplate and ConcurrentKafkaListenerContainer). I want to make this project a reusable library accross a set of Spring boot applications. But when I add dependency to this library from a spring boot app I get an error at app startup:</p>
  
  <pre><code>APPLICATION FAILED TO START
  
  
  Description:
  
  Parameter 1 of method kafkaListenerContainerFactory in org.springframework.boot.autoconfigure.kafka.KafkaAnnotationDrivenConfiguration required a bean of type 'org.springframework.kafka.core.ConsumerFactory' that could not be found.
      - Bean method 'kafkaConsumerFactory' in 'KafkaAutoConfiguration' not loaded because @ConditionalOnMissingBean (types: org.springframework.kafka.core.ConsumerFactory; SearchStrategy: all) found bean 'kafkaConsumerFactory'
  
  
  Action:
  
  Consider revisiting the conditions above or defining a bean of type 'org.springframework.kafka.core.ConsumerFactory' in your configuration.
  </code></pre>
  
  <p>Since I need to autowire a <code>ConsumerFactory&lt;A, B&gt;</code> (and not a <code>ConsumerFactory&lt;Object, Object&gt;</code>) I create this bean in a configuration class that's annotated with @EnableConfigurationProperties(KafkaProperties.class) </p>
  
  <p>All I need is to reuse org.springframework.boot.autoconfigure.kafka.KafkaProperties without other beans being autoconfigured in KafkaAutoConfiguration and KafkaAnnotationDrivenConfiguration.</p>
  
  <p>I've tried to put <strong>@EnableAutoConfiguration(exclude = KafkaAutoConfiguration.class)</strong> in my library but this is not preventing applications that depends on my library to trigger the spring-kafka autoconfiguration excluded in the library.</p>
  
  <p>How can I specify that I don't want autoconfiguration of some beans (KafkaAutoConfiguration and KafkaAnnotationDrivenConfiguration) in my library but <strong>also in any app that depends on this library</strong>?</p>