Spring @ComponentScan Spring @ComponentScan is an interface and it is part of the package " org.springframework.context.annotation ". It will enable component scanning in the Spring application. Component scanning enables auto-detection of beans by Spring Container. Java classes decorated with stereotypes such as @Configuration , @Component , @Service , @Controller, and @Repository are auto-detected by Spring. We can annotate component scan with or without arguments. Either basePackageClasses() or basePackages() (or it's alias value()) may be specified to define the specific packages to scan. @ComponentScan WITHOUT arguments tells Spring to scan the current package and all of its sub-packages. For example : import org.springframework.context.annotation. ComponentScan ; @ComponentScan public class MovieApplication { } @ComponentScan WITH arguments tells Spring to scan the package mentioned with an attribute basePackages. For example: import org.springframewor...
Comments