The @ComponentScan annotation in Spring, located within the org.springframework.context.annotation package, helps automatically detect beans in a Spring application. It can identify classes annotated with stereotypes like @Configuration, @Component, @Service, @Controller, and @Repository. The annotation can be used with or without parameters, such as basePackageClasses() or basePackages(), to specify scanning packages. It essentially replaces the XML tag <context:component-scan/> and includes various attributes for customizing the component scanning process, like nameGenerator, scopeResolver, scopedProxy, useDefaultFilters, includeFilters, and excludeFilters.

5m read timeFrom foojay.io
Post cover image
Table of contents
Author(s)Attributes used with ComponentScan annotationConclusionReference

Sort: