Add TestExcludeFilter for component scanning

Add a new TypeFilter specifically for excluding candidate components.
The filter is applied to `@SpringBootApplication` and allows tests to
dynamically contribute exclude filters so that specific classes of
component can be excluded.

See gh-5295
See gh-4901
This commit is contained in:
Phillip Webb
2016-03-01 15:35:45 -08:00
parent 965dd33ec8
commit 513dec718f
6 changed files with 229 additions and 1 deletions

View File

@@ -24,9 +24,12 @@ import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.boot.context.TypeExcludeFilter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.ComponentScan.Filter;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.FilterType;
import org.springframework.core.annotation.AliasFor;
/**
@@ -46,7 +49,7 @@ import org.springframework.core.annotation.AliasFor;
@Inherited
@SpringBootConfiguration
@EnableAutoConfiguration
@ComponentScan
@ComponentScan(excludeFilters = @Filter(type = FilterType.CUSTOM, classes = TypeExcludeFilter.class))
public @interface SpringBootApplication {
/**