I have lots of controller classes in my project some annotated with @RestController and the rest annotated with @Controller and @ResponseBody. The whole base package is getting component scanned in both root context Spring config class and and web app context Spring config class. I want to use Component Filters to stop controller classes being scanned when initializing the root context. I tried the following but it didn't work as expected. I still see the Controller classes being present in the root app context.
@Configuration
@ComponentScan(basePackages = {"com.xxx.yyy"}, excludeFilters = {
@ComponentScan.Filter(type = FilterType.ANNOTATION, value = Controller.class)})
public class RootSpringConfig {
}
Also tried using RestController.class and both but still no luck. I believe Controller.class alone should work as RestController is a wrapper around Controller and ResponseBody. I do have all my controller classes ending with *Controller in the class name is there a way to use regex to filter classes which ends with controller and/or make annotation filter work as expected.