注入复杂的类属性
private String name;
private int age;
private List course;
private Map<String,String> map;
beans.xml配置
<bean id="student" class="com.model.Student">
<property name="name" value="liuhao"></property>
<property name="age" value="18"></property>
<!-- <property name="object" ref="属性类的bean的id"></property> -->
<property name="course" >
<list>
<value>100</value>
<value>99</value>
<value>66</value>
</list>
</property>
<property name="map">
<map>
<entry>
<key><value>home</value></key>
<value>henan</value>
</entry>
<entry>
<key><value>aihao</value></key>
<value>nv</value>
</entry>
</map>
</property>
</bean>
加载beans配置的类
ApplicationContext path = new ClassPathXmlApplicationContext("beans.xml");
Student student = path.getBean("student", Student.class);//(bean的id,Student.class)
System.out.println(student);
自动装配方式
https://www.cnblogs.com/kuotian/p/8795812.html
<bean id="dog" class="com.hdu.autowire.Dog"></bean>
<bean id="cat" class="com.hdu.autowire.Cat"></bean>
<bean id="user" class="com.hdu.autowire.User" autowire="byName" scope="prototype">
<property name="str" value="liuhao"></property>
</bean>
bean的作用域