How to config @ComponentScan dynamic?
@ComponentScan( //CS1 basePackages = {"com.package.A", "com.package.B"}, excludeFilters = @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = {com.Package.A.SomeClass.class }) ) @ComponentScan( //CS2 basePackages = { "com.package.A"} ) @EnableAutoConfiguration @SpringBootApplication public class Application { public static void main(String[] args) throws Exception { ConfigurableApplicationContext ctx = SpringApplication.run(Application.class, args); } } Above is my SpringBootApplication 's main class. As you can see,I have to use Annnotation ,not xml . There are two @ComponentScan