<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="helloworld" class="Person">
</bean>
<!-- 'ref' 属性来连接 bean-->
<bean id="customer" class="Customer">
<property name="person" ref="person"></property>
</bean>
<!-- Spring会自动通过setter方法将其装配 – “setPerson(Person person)-->
<bean id="customer1" class="Customer" autowire="byName"></bean>
<!-- “Person” bean中的数据类型是与“customer” bean的属性(Person对象)的数据类型一样的 -->
<bean id = "customer2" class="Customer">
</bean>
<!-- 由于“person” bean的数据类型与“customer” bean的属性(Person对象)的构造函数参数的数据类型是一样的,所以,Spring通过构造方法自动装配 – “public Customer(Person person)“-->
<bean id="customer3" class="Customer" autowire="constructor">
</bean>
<bean id="person" class="Person"></bean>
</beans>
<bean id="person2" class="Person">
</bean>
<!-- 'ref' 属性来连接 bean-->
<bean id="customer" class="Customer">
<property name="person" ref="person"></property>
</bean>
<!-- Spring会自动通过setter方法将其装配 – “setPerson(Person person)-->
<bean id="customer1" class="Customer" autowire="byName"></bean>
<!-- “Person” bean中的数据类型是与“customer” bean的属性(Person对象)的数据类型一样的 -->
<bean id = "customer2" class="Customer">
</bean>
<!-- 由于“person” bean的数据类型与“customer” bean的属性(Person对象)的构造函数参数的数据类型是一样的,所以,Spring通过构造方法自动装配 – “public Customer(Person person)“-->
<bean id="customer3" class="Customer" autowire="constructor">
</bean>
<bean id="customerBean" class="Customer">
<property name="name" value="abc"></property>
</bean>
<bean id="person" class="Person"></bean>