Bean
- id :名称
- class:全限定类名
- scope:指定范围
- init_method:指定初始化函数
- destroy_method:指定销毁
Scope
- singleton:单例
- prototype:多例
- request
- session
- global_session
singleton:
容器产生对象产生,容器销毁对象销毁
prototype:
什么时候使用对象,什么时候产生;不使用时,java回收机制,回收对象
bean实例化方式
默认构造函数
<bean id="自定义名称" class="全限定类名"></bean>
静态工厂
<bean id="自定义名称" class="全限定类名" factory_method="类的静态函数">
实例化工厂
<bean id="自定义名称1" class="全限定类名1"></bean>
<bean id="自定义名称2" factory_bean="自定义名称1" factory_method="函数名">
注入
构造函数(类里面的有构造函数)
<constructor-arg name=" " value="" ref=""></constructor-arg>
set注入(类里有相应属性的set方法)
<property name=" " value="" ref=""> </property>
集合属性注入
1.list set array(list类型)
2.entry map props prop(map结构)