I have a Test class:
@ComponentScan(basePackageClasses = {MyAppConfig.class}, excludeFilters = {@ComponentScan.Filter(classes = {OtherTest.ConflictsWithAppTestConfig.class})})
...
public class MyAppTest { ... }
and an additional unrelated Test class:
public class OtherTest {
@Configuration
public static class ConflictsWithAppTestConfig { ... }
}
with the following directory structure:
src/java/com/example
\_ MyAppConfig.java
\_ somesubdirectory
\_ <more spring components>
...
test/java/com/example
\_ MyAppTest.java
\_ OtherTest.java // with OtherTest.ConflictsWithAppTestConfig
The @ComponentScan.Filter
allows me to stop importing the OtherTest.ConflictsWithAppTestConfig
in MyAppTest
when using @ComponentScan
.
This works, however as I add more test cases under the same base, maintaining this list of excluded classes will grow with respect to other test classes under the same package with @ComponentScan
.
How can I setup the @ComponentScan
filter to only include src
directory configurations to let me import test
configurations manually?
i.e. fill in the blanks:
@ComponentScan(..., excludeFilters = {@ComponentScan.Filter(type=???, pattern=???)}