Skip to main content

Component Scanning

Learn Component Scanning (Spring MVC Configuration, Spring MVC) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Fresher Notes Component scanning makes Spring search packages for classes marked @Component (or @Controller , @Service , @Repository ) and register them as beans. Enable it with @ComponentScan("com.example") on a configuration class, or <context:component-scan> in XML. Result : you do not write @Bean methods or XML for each class; annotating the class is enough.

More lessons in Spring MVC Configuration