1.P Namespaces
Attribute Injection Reference
<property name= "CD" ref= "CD"/>
<p:cd-ref= "CD"/>
Attribute injection literal
<property name= " property " value= " literal " />
<property name ""/>
<list>
<value>123</value>
</list>
</property>
<bean id= "123" class= "XXX"
P. Property = "XX"
2.util- Namespaces
<util-list> elements Create a list bean
<util-list id = "Ulist" >
<value>1</value>
<value>2</value>
<value>3</value>
</util-list>
The list Bean can now be injected into the property
<bean id= "123" class= "XXX"
P.tracks-ref = "Ulist"
</bean>
Besides, there are elements such as Util-map Util-set
2.5.1 referencing XML configuration in Javaconfig
Split Javaconfig class
1) use @Import annotations in the original javaconfig to import the cdconfig
@Import (Cdconfig.class)
2) take a better approach to creating a higher -level soundsystemconfigthat is used in this class @Import Annotations combine two configuration classes together.
@Import {cdconfig.class,Cdplayerconfig.class}
simultaneous loading based on configuration of XML and JAVA
1) using @ImportResource annotations
@Configuration
@import (Cdplayerconfig)
@import ("Classpath:cd-config.xml")
public class soundsystemconfig{}
two beans will be loaded into the spring container.
2.5.2 referencing Javaconfig in XML
Split XML Configuration
1) Use the <import> element to reference the XML file
2) use <bean> tags to import JAVA configuration
<beans
<bean class = "Soundsystem.cdconfig"/>// import java configuration
<bean id= "CDPlayer"//xml configuration
class = "Soundsystem.cdplayer"
c:cd-ref= "CD"
/>
</beans>
3) The same method, you can create a higher level of the configuration file, this file does not declare any beans, is only responsible for multiple configurations together
usually regardless of the use XML configuration or javaconfig configuration, we typically create a root configuration , which enables component scanning in the root configuration.
by <Context:conponent-scan> or @ConponentScan
(To change the project series) Spring Study notes (1)