Exclude subpackages from Spring autowiring?

后端 未结 9 895
傲寒
傲寒 2020-12-02 10:00

Is there a simple way to exclude a package / sub-package from autowiring in Spring 3.1?

E.g., if I wanted to include a component scan with a base package of co

9条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-02 10:43

    You can also use @SpringBootApplication, which according to Spring documentation does the same functionality as the following three annotations: @Configuration, @EnableAutoConfiguration @ComponentScan in one annotation.

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

提交回复
热议问题