ThanksItcastFree video released.
@ AutowireInjection by type by default
@ Autowired @ qualifier ("persondaoxxx ")In this way, the component is assembled by name.
@ Autowired(Required = true) Must be injected, cannot beNull,IsFalseNo matter what value is injectedNull
All of the above are manually assembled.
Automatic Assembly of dependent objects
For automatic assembly, you can understand it. It is not recommended. Example:
<Bean id = "..." Class = "...">
AutowireThe attribute values are as follows:
bytype : assemble by type, which can be based on the attribute type, search for the bean. if multiple roles are found, an exception is thrown. If not found, the attribute value is null .
byname : Name-based assembly, which can be based on the attribute name, find the bean with the same root attribute name in the container, if not found, that is, the attribute value is null .
constructor and bytype method is similar, the difference is that it is applied to the constructor parameters. If the bean with the same type as the constructor parameter is not found in the container, An exception is thrown.
Autodetect: PassBeanClass introspection mechanism to decide to useConstructorOrBytypeMethod for Automatic Assembly. If the default constructor is foundBytypeMethod.