@ Component: Mark a common spring Bean class
@ Controller: Mark A Controller component class
@ Service: Mark a business logic component class
@ Repository: Mark a DaO component class
The Convention is to change the first letter of the bean class to lowercase, And the other parts remain unchanged.
@ Scope specify the scope
@ Resource specifies the configuration dependency
@ Autowired: automatic assembly. The default value is bytype. One field is configured in an instance. If multiple fields are configured, the field [] array is used. If the set field is configured, the generic field must be used.
@ Qualifier precise automatic assembly, byname
<context:component-scan base-package=".."> <context:include-filter type="regex" expression=".*XXX"/> <context:exclude-filter type="regex" expression=".*XXX"/></context:component-scan?
The autowire property value is
Byname
Automatic Assembly based on whether the alias specified in the "ID" attribute of bean definition is consistent with the setter name
Bytype
Based on the Type accepted by the setxxx () method of pojo, determine whether the bean definition file defines similar type objects for automatic assembly.
Constructor
The spring container compares the bean instance type in the container with the parameter types in the relevant constructor for automatic assembly.
Autodetect
Automatic constructor assembly is performed first. If default, automatic bytype assembly is performed.
No. automatic assembly is not performed.
Depends-on
If a depends-on B means that B must be instantiated before a is instantiated, but a does not need to hold B's instance.
Abstract Attribute Value
False default
Ture indicates abstract bean. All abstract bean definitions are ignored during pre-initialization of applicationcontext.
Parent
Indicates that the bean is a child bean, and its value points to the parent bean to reuse the dependencies implemented by the parent bean.
Dependency-check Attribute Value
Simple
Only check whether the dependency of a simple attribute is complete.
Objects
Check whether the dependency of the Object Type property is complete.
ALL: Check whether all attributes have completed dependencies.
Default Value of none, indicating no dependency check
Singleton Attribute ValueSpecifies whether the Java Bean adopts Singleton mode.
If this parameter is set to false, a new Java Bean instance is created in beanfactory.
True (default) means that only one Java Bean instance is maintained within the scope of beanfactory. The Code obtains reference of this Java Bean instance through beanfactory.
Init-Method
Initialization method. This method will be executed after beanfactory creates a JavaBean instance and property set injection before returning a reference to the application layer. It is generally used for initialization of some resources.
Destroy-MethodDestruction method. This method will be executed when beanfactory is destroyed and is generally used for resource release.
Lazy-init Attribute Value
True: delayed loading, that is, the IOC container will be instantiated only when it is used for the first time.
False default
Factory-beanCreate a bean using the instance factory method. The class attribute must be empty, and the factory-bean attribute must specify the name of a bean. The Bean must be in the current Bean factory or parent Bean factory, and include the factory method. The factory method itself is set through the factory-method attribute.
Factory-Method
Define the factory method. If the class property points to the factory class, the factory method contained in the factory class must be static.