Is there any annotation or trick usable in a class to autoexclude itself from any contextscan?
My question is specific on whether a class can autoexclude itself from any contextscan, I know how to do it by exception from the @contextScan itself
Is there any annotation or trick usable in a class to autoexclude itself from any contextscan?
My question is specific on whether a class can autoexclude itself from any contextscan, I know how to do it by exception from the @contextScan itself
If you mean @ComponentScan then no, there is no annotation that will do this. The exclude filter on component scan may help though;
@ComponentScan(
excludeFilters=@ComponentScan.Filter(
type=FilterType.ANNOTATION, value=Controller.class))
I would recommend making your scans more specific so that each config class only scans for specific types (with includeFilter), you get more configuration classes but it's easier to control what they are doing.