Spring
June 2, 2020

M01 Q15 What does component-scanning do?

Component Scanning

Process in which Spring is scanning Classpath in search for classes annotated with stereotypes annotations (@Component, @Repository, @Service, @Controller, …) and based on those creates beans definitions.

Simple component scanning within Configuration package and all sub-packages.

Advanced Component Scanning Rules

In the above example, component scanning will search for beans in the package. And beans with the name ends with "Bean" will be included. And beans that contain "Controller" or "Service" in their names will be excluded.