ComponentScan.Filter not filtering @Configuration class. I'm using spring boot 2.2.12 with spring-context 5.2.12.
SpringBoot class
@EnableMBeanExport
@ComponentScan(basePackages = "com.init”,
excludeFilters = {
@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = com.init.server.ServerAConfig.class)})
@SpringBootApplication()
public class MyApplication extends SpringBootServletInitializer {
public static void main(String[] args) throws IOException {
SpringApplication.run(MyApplication.class);
}
}
Under the basepackage com.init, there is a configurtion class ServerAConfig.
@Configuration
@ComponentScan(basePackages = {"com.execute.server”})
public class ServerAConfig {
}
Under package com.execute.server I have class MyServerA.java
My expectation was, MyServerA will not be available in the ApplicationContext
for (String beanName : applicationContext.getBeanDefinitionNames()) {
System.out.println(beanName);
}
but when i run the above print after the boot up it shows MyServerA there in the ApplicationContext. My expectation was MyServerA will not be initialized. Also tried with different FilterType.