Exclude subpackages from Spring autowiring?

后端 未结 9 898
傲寒
傲寒 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:57

    You can also include specific package and excludes them like :

    Include and exclude (both)

     @SpringBootApplication
            (
                    scanBasePackages = {
                            "com.package1",
                            "com.package2"
                    },
                    exclude = {org.springframework.boot.sample.class}
            )
    

    JUST Exclude

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

提交回复
热议问题