The @ComponentScan annotation allows the autoscanning of beans. It takes a few arguments, such as base packages and their classes. The Spring container then looks into all the classes inside the base package and looks for beans. It scans all classes annotated with @Component or other annotations that are meta-annotated with @Component, such as @Configuration, @Controller, and so on.
By default, Spring Boot takes the default base package from the class, which has the @ComponentClass annotation. You can use the basePackageClasses attribute to identify which packages should be scanned.
Another way to scan more than two packages is by using the basePackages attribute. It allows you to scan more than one package.
If you want to use more than one @ComponentScan, then you can wrap them inside the @ComponentScans annotation as shown: