* You are viewing the archive for the ‘Spring Framework’ Category

Custom scanners in Spring Framework with example

With the 2.5 version of Spring Framework [1] we don’t need to implicitly declare beans in application context’s xml. Simply put, adding this entry to xml

<context:component-scan base-package="org.example.package" />

will instruct Spring to scan specified base package for beans that have special annotations. It could be @Component, @Controller, etc…

But what if we need to declare our own custom scanner, that searches for specific type of classes and initialize them as a beans and apply additional logic. Spring comes in very handy.

Continue Reading »