Spring boot ComponentScan excludeFIlters not excluding

前端 未结 2 478
栀梦
栀梦 2021-02-05 12:37

I am having a SimpleTest :

@RunWith(SpringRunner.class)
@SpringBootTest(classes = SimpleTestConfig.class)
public class SimpleTest {
    @Test
           


        
2条回答
  •  醉梦人生
    2021-02-05 13:03

    You can define custom component scan filter for excluding it.

    Example code will be like:

    @SpringBootApplication()
    @ComponentScan(excludeFilters=@Filter(type = FilterType.REGEX, pattern="com.wyn.applications.starter.Starter*"))
    public class SimpleTestConfig {
    
    }
    

    This works for me.

    For further reading go to this blog.

提交回复
热议问题