I want to exclude some packages from being scanned when using spring @SpringBootTest
in the same way it is done with @ComponentScan
.
Is there something like
@SpringBootTest(excludeFilters [email protected](
type = FilterType.REGEX,
pattern = "package\\.\\.to\\.Exclude.*"))
It seems that the best workaround on this is to create a class annotated with the @SpringBootApplication
and configure the scanning configuration there
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication(scanBasePackageClasses ={TestConfiguration.class})
public class TestApp {
}
Then your unit test you should specify the test class created previously
@SpringBootTest(classes = TestApp.class)
public class UnitTestClass {
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With