ComponentScan excludeFilters Not Working In Spring 4.0.6.RELEASE

前端 未结 3 969
臣服心动
臣服心动 2020-12-28 08:31

I have a class which I want to exclude while component scanning. I am using the below code to do that but that doesn\'t seem to work although everything seems to be right

3条回答
  •  Happy的楠姐
    2020-12-28 08:46

    At first,Thanks very much about the answers of @Yuriy and @ripudam,but what makes me confused is when my excludeFilters contains Configuration.class I have to use @Import to import the Classe which annotated by @Configuration.I found when i use excludeFilters = {@Filter(type = FilterType.ANNOTATION,value{EnableWebMvc.class,Controller.class}),all works well.The ContextLoaderListener doesn`t regist the Controller at first.

    For example

    //@Import(value = { SecurityConfig.class, MethodSecurityConfig.class, RedisCacheConfig.class, QuartzConfig.class })
    @ComponentScan(basePackages = { "cn.myself" }, excludeFilters = {
            @Filter(type = FilterType.ANNOTATION,value={EnableWebMvc.class,Controller.class}) })
    public class RootConfig {
    }
    

提交回复
热议问题