ID and name
ID has a naming limit, such as must start with a letter, the ID must be unique in the configuration file
Name does not have a naming limit, you can have more than one name Bean,getbean in the configuration file when you return the last defined bean
If neither is defined, the example <bean class= "ABC.A", the default is the fully qualified class name for the Bean, Getbean ("ABC.A");
If neither is defined and there are multiple <bean class= "ABC.A", the first bean is obtained with Getbean ("ABC.A"), the second is obtained with Getbean ("abc.a#1"), and so on.
Attribute Injection
Naming rules, either the first two letters are capitalized, or all lowercase
Note 5 special characters when a value is literal &<> "', if the value contains special characters, there are two solutions, one is <! [cdata[]]> and the other is special character substitution, such as < replace with <
The <ref> element is available when the value is a reference, contains three attributes: Bean (bean referencing the same container or parent container), local (bean that references the same configuration file only), parent (the bean referencing the parent container)
If not referenced, you can also use the internal bean configuration, that is, the bean definition within the property element, the bean can only be used for the corresponding external bean, not for other bean references
A null value, if the property value wants to be a null value, cannot be like this <property name= "abc" ><VALUE></VALUE></PROPERTY>, which means that the value is an empty string, Should be for such <property name= "abc" ><value><null/></value></property>
Properties is similar to map, except that the properties ' key value can only be a string
Constructor injection
It is best to add indexes and types to the configuration items, such as: <constructor-arg index= "0" type= "java.lang.String" > <value>abc</ value></constructor-arg>,0 represents the first argument, and type represents the parameter type, which allows you to precisely locate which constructor in the class
Parent-Child bean (collection merge)
The child bean inherits the properties of the parent bean, which is typically set to abstract= "true" (which means that it does not need to be instantiated), parent= "XXX" is written in the subclass, and if the property has the same name, the child bean overrides the parent bean property, and if it wants to merge the attributes, For example, the parent class has a property that is a set type, and a subclass has a set type, and if you want to merge the attributes, you need to write merge= "true" in the corresponding property.
Simplified configuration
Of course, it can be more concise, that is, referring to the P namespace, format p: Property name = "xxx", p: Property name _ref= "XXX".
Spring Bean definition