Spring study notes - automated assembly Bean

Spring from two angles to automate the assembly:
component scans (component scanning): Spring application context automatically find
the bean created.
Automatic assembly (autowiring): Spring automatically satisfy the dependencies between the bean.

@Component comment. This simple
single annotation class will show as a component class, and told the class to be created Spring
bean. Components scanning is not enabled by default, use @ComponentScan annotation, this annotation can start in Spring
with a component scans.

Enter the value of the corresponding attribute @ComponentScan package name, the package can be scanned to determine the
Here Insert Picture Description
packet type set to String is unsafe, if refactoring code, then the specified base package might mistake occurred.
Thus we can specify that a class or interface packet contained:
Here Insert Picture Description

Published 25 original articles · won praise 22 · views 3641

Guess you like

Origin blog.csdn.net/weixin_42443419/article/details/103618837