Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

spring component scan for classes

Tags:

spring

I want to scan all the classes in a package that that are subclasses of the particular class. Then I want to take these classes and for each of them instantiate a bean of same type, using the class as a property. Then I want to gather all these anonymous beans and put them into collection. Is it possible to configure spring context in XML like this? Thx

like image 639
awk Avatar asked May 08 '26 19:05

awk


1 Answers

Just use this class:

ClassPathScanningCandidateComponentProvider

method: findCandidateComponents.
like image 63
Carlos Lopez Avatar answered May 11 '26 15:05

Carlos Lopez