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
In addition to the method described by Emerson Farrugia there is a less verbose solution which has been supported since Spring Framework 4.2 as mentioned in the documentation here.
As of Spring Framework 4.2,
@Importalso supports references regular component classes, analogous to theAnnotationConfigApplicationContext.registermethod. This is particularly useful if you want to avoid component scanning, by using a few configuration classes as entry points to explicitly define all your components.
So your example would simply become:
@Import(YourClass.class)