-1

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

Whimusical
  • 6,401
  • 11
  • 62
  • 105
  • For any context scan I don't know as beans doesn't provide this feature. Now, you can exclude it from a specific Spring configuration with the @ComponentScan annotation for example. – davidxxx Jul 10 '17 at 19:56
  • 2
    Have a look at this suggestion: https://stackoverflow.com/a/27344579/2210137 – msfoster Jul 10 '17 at 19:56
  • Possible duplicate of [exclude @Component from @ComponentScan](https://stackoverflow.com/questions/18992880/exclude-component-from-componentscan) – Alexander Jul 10 '17 at 21:37
  • 1
    I don't understand. A type without one of the `@Component` stereotypes will be ignored. Just remove that annotation. – Sotirios Delimanolis Jul 10 '17 at 23:47

1 Answers1

0

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.

GrumpyWelshGit
  • 587
  • 4
  • 14