012.基于构造方法注入对象
1.applicationContext.xml
<bean id="andy" class="com.imooc.spring.ioc.entity.Child"> <constructor-arg name="name" value="安迪"/> <constructor-arg name="apple" ref="sourApple"/> </bean>
2.Apple.java
构造方法: public Child(String name, Apple apple) { System.out.println("构造方法参数apple:" + apple); this.name = name; this.apple = apple; }