title: Exclude @Configuration from Spring Boot Application
body: <p>I have bunch of modules (say 3). Two are Spring boot based module and another one is Spring based.
  Say Module 1 - SpringBoot
      Module 2 - Spring Boot
      Module 3 - Common Module only Spring based</p>
  
  <p>Module 3 @Configuration file defined which needs to be picked only by Module 2 and not 1. </p>
  
  <p>I tried bunch of things to exclude the configuration file. For ex:- </p>
  
  <pre><code>@SpringBootApplication
  @ComponentScan(basePackages = {"com.adobe"}
  , excludeFilters = {
      @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {WorkerConfig.class, WorkerExecutors.class, Worker.class})})
  public class Application {
  
    private static final Logger logger = LoggerFactory.getLogger(Application.class);
  
    public static void main(String[] args) throws Exception {
      SpringApplication.run(Application.class, args);
    }
  
  }
  </code></pre>
  
  <p>But Still the @Configiration Class is not getting excluded and Spring is trying to load it in application context which I dont want. My config class</p>
  
  <pre><code>@Configuration
  public class WorkerConfig {
  
    @Bean
    public WorkerExecutors workerExec() {
      WorkerExecutors executors = new WorkerExecutors();
      return executors;
    }
  
  }
  </code></pre>
  
  <p>Also I do read in @ComponentScan annotation that </p>
  
  <pre><code> * &lt;p&gt;Note that the {@code &lt;context:component-scan&gt;} element has an
   * {@code annotation-config} attribute; however, this annotation does not. This is because
   * in almost all cases when using {@code @ComponentScan}, default annotation config
   * processing (e.g. processing {@code @Autowired} and friends) is assumed. Furthermore,
   * when using {@link AnnotationConfigApplicationContext}, annotation config processors are
   * always registered, meaning that any attempt to disable them at the
   * {@code @ComponentScan} level would be ignored.
  </code></pre>
  
  <p>So looks like excluding in Component Scan wont work.  Other than above, I also tried excluding using </p>
  
  <pre><code>@SpringBootApplication(exclude= {WorkerExecutors.class, Worker.class,WorkerConfig.class})
  public class Application {
  </code></pre>
  
  <p>But spring boot throws </p>
  
  <pre><code>java.lang.IllegalStateException: The following classes could not be excluded because they are not auto-configuration classes:
      - com.adobe.repository.worker.lib.config.WorkerConfig
      - com.adobe.acp.repository.worker.lib.core.WorkerExecutors
      - com.adobe.acp.repository.worker.lib.core.Worker
  </code></pre>
  
  <p>Any idea how can I disable component scanning a non spring boot module in  a spring boot module other than putting in a different package. I dont want to put in different package.</p>
  
  <p>Any help is appreciated!!</p>