Reputation: 30097
If I write only
@ComponentScan
Spring will scan the current package and below.
If I write
@ComponentScan(basePackages = {"my.package.com"})
Can I specify current package implicitly along with some explicit packages?
Something like this
@ComponentScan(basePackages = {"", "my.package.com"})
Upvotes: 1
Views: 1272
Reputation: 8641
The JavaDoc says:
If specific packages are not defined, scanning will occur from the package of the class that declares this annotation.
So if you declare any package to be scan the default behavior will be overridden. However I cannot see the reason why you need to have implicit scan for current package as long as it is not something that will be changed in runtime. If you want to protected yourself in case of refactoring, you can use Type-safe basePackageClasses instead:
@ComponentScan(basePackageClasses = {Config.class, ClassInPackageToScan.class})
Upvotes: 2