Using the basePackageClasses attribute in ComponentScan

When using component scan, we recommend that you use the basePackageClasses attribute. The following snippet shows an example:

    @ComponentScan(basePackageClasses = ApplicationController.class) 
public class SomeApplication {

The basePackageClasses attribute is the type-safe alternative to basePackages() in order to specify the packages to scan for the annotated components. The package of each specified class will be scanned.

This will ensure that even when the package is renamed or moved, the component scan would work as expected.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset