Wednesday, August 19, 2020

Spring - Component Scanning

 Component scanning scans a base package and loads configuration automatically for each bean it finds. Component scanning occurs at the application startup. The base package can be defined in java or xml configuration.


@Component

@Component indicates that the class should be loaded in the BeanFactory. Tells spring to include this class in component scanning.

@Component is the root annotation and it have several stereotypes, like @Service


@Autowired

@Autowired indicates that class has a dependency on the bean, which is used by spring IoC to inject the dependency.


@Qualifier

@Qualifier is used when multiple implementation of an interface are needed


@Value

properties are injected with @Value annotation.



No comments:

Post a Comment

Spring - AutoWiring

Spring automatically resolves the dependencies between the collaborating beans by inspecting the contents of the BeanFactory. This is called...