exclude @Component from @ComponentScan

后端 未结 7 1478
暖寄归人
暖寄归人 2020-11-28 04:10

I have a component that I want to exclude from a @ComponentScan in a particular @Configuration:

@Component(\"foo\") class Foo {
...         


        
7条回答
  •  佛祖请我去吃肉
    2020-11-28 04:25

    In case you need to define two or more excludeFilters criteria, you have to use the array.

    For instances in this section of code I want to exclude all the classes in the org.xxx.yyy package and another specific class, MyClassToExclude

     @ComponentScan(            
            excludeFilters = {
                    @ComponentScan.Filter(type = FilterType.REGEX, pattern = "org.xxx.yyy.*"),
                    @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = MyClassToExclude.class) })
    

提交回复
热议问题