ComponentScan excludeFilters Not Working In Spring 4.0.6.RELEASE

前端 未结 3 977
臣服心动
臣服心动 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条回答
  •  醉酒成梦
    2020-12-28 08:42

    I had an issue when using @Configuration, @EnableAutoConfiguration and @ComponentScan when trying to exclude specific configuration classes, but it didn't work!

    Eventually I solved the problem by using @SpringBootApplication, which according to Spring documentation does the same functionality as the three above in one annotation.

    Another Tip is to try first without refining your package scan (without the basePackages filter).

    @SpringBootApplication(exclude= {Foo.class})
    public class MySpringConfiguration {}
    

提交回复
热议问题