Using @ComponentScan or with only one class

后端 未结 4 588
鱼传尺愫
鱼传尺愫 2020-12-06 03:56

I\'m maintaining a project with two set of main packages, the project is using Spring and Spring MVC, one of these packages contains several controllers and is scanned using

4条回答
  •  南笙
    南笙 (楼主)
    2020-12-06 04:44

    What @Bart said for XML.

    If you need to pull in that one class using annotations, add the following to one of your @Configuration classes

    @ComponentScan(
        basePackageClasses = YourClass.class, 
        useDefaultFilters = false,
        includeFilters = {
            @ComponentScan.Filter(type = ASSIGNABLE_TYPE, value = YourClass.class)
        })
    

提交回复
热议问题