It does scan all classes that match the given pattern - but it looks for annotations instead of interfaces. Details are covered in this section of the Spring docs.

It's also not necessarily "efficient" - it just loads the classes and uses reflection to find matching annotations. To prevent long startup times, it's better to be very specific in the pattern that you tell it to match - if you pass it a package path that contains a bunch of classes, it will take time to scan all of them.

Nathan Pruett wrote:It does scan all classes that match the given pattern - but it looks for annotations instead of interfaces. Details are covered in this section of the Spring docs.

It's also not necessarily "efficient" - it just loads the classes and uses reflection to find matching annotations. To prevent long startup times, it's better to be very specific in the pattern that you tell it to match - if you pass it a package path that contains a bunch of classes, it will take time to scan all of them.

Actually, you just describe component-scan not autowiring. ;)

For autowiring, Spring looks at just the Spring Beans that it created for an object of the type that needs to be injected into the other bean. You don't/can't filter this. Spring will go through all your beans that it knows about, it won't go outside of those classes.