I have a spring app that is configured for Component Scanning, is there a flag or option that I can turn on that would cause spring to print out the fully qualified names of the classes that the spring framework scanner picks up?
Using @ComponentScan in a Spring Application. With Spring, we use the @ComponentScan annotation along with the @Configuration annotation to specify the packages that we want to be scanned. @ComponentScan without arguments tells Spring to scan the current package and all of its sub-packages.
For example , it has an attribute called scanBasePackages which tells Spring to scan the beans (A class that is annotated with @Component or its sterotypes such as @Service , @Repository , @Controller etc. ) from certain packages and its sub-packages only.
In order to activate them, we can add either <context:annotation-config> or <context:component-scan> on top of our XML file. In this section, we'll see how <context:annotation-config> and <context:component-scan> differ from each other in terms of their ways of activating annotations.
Spring provides a mechanism to identify Spring bean candidates explicitly through the @ComponentScan annotation. If the application is a Spring Boot application, then all the packages under the package containing the Spring Boot application class will be covered by an implicit component scan.
You can print this by configuring logging category (assuming you are using log4j), set org.springframework.context.annotation
at debug level.
Check org.springframework.context.annotation.ClassPathScanningCandidateComponentProvider.findCandidateComponents(String)
.
You can see the class is logging name of the classes at debug level. Verified in Spring 3.0.5 version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With