spring实例化bean以及构造器装配属性
来源:互联网 发布:sql 添加合计行 编辑:程序博客网 时间:2024/05/29 13:58
1、使用类构造器实例化 90%
<bean id="personService" class="com.insigma.service.impl.PersonServiceBean"></bean>
2、使用静态工厂方法实例化
<bean id="personService" class="com.insigma.service.PersonServiceBeanFactory" factory-method="createPersonServiceBean"></bean>
public class PersonServiceBeanFactory
{
public static PersonServiceBean createPersonServiceBean()
{
return new PersonServiceBean();
}
}
3、使用实例化工厂方法实例化
<bean id="personServiceFactory" class="com.insigma.service.PersonServiceBeanFactory" ></bean>
<bean id="personService" class="com.insigma.service.PersonServiceBeanFactory" factory-bean="personServiceFactory"factory-method="createPersonServiceBean"></bean>
public class PersonServiceBeanFactory
{
public PersonServiceBean createPerson()
{
return new PersonServiceBean();
}
}
private PersonDao personDao;
private String personName;
private int personAge;
public PersonServiceBean(PersonDao personDao, String personName,
int personAge) {
this.personDao = personDao;
this.personName = personName;
this.personAge = personAge;
}
<bean id="personService" class="com.insigma.service.impl.PersonServiceBean" init-method="initBean" destroy-method="destoryBean">
<!-- <property name="personDao" ref="personDao"></property>
<property name="personName" value="张三"></property>
<property name="personAge" value="33"></property> -->
<constructor-arg index="0" type="com.insigma.dao.PersonDao" ref="personDao" />
<constructor-arg index="1" type="String" value="张三" />
<constructor-arg index="2" type="int" value="33" />
</bean>
- spring实例化bean以及构造器装配属性
- spring装配Bean过程以及Bean实例化过程
- Spring(六)使用构造器装配属性
- spring自动装配Bean属性
- Spring自动装配Bean属性
- Spring 自动装配Bean属性
- Spring 装配Bean的构造注入
- Spring(四)基于XML装配bean(实例化方式)
- Spring bean属性注入(构造器)
- Spring <bean>标签属性 Autowire自动装配
- Spring <bean>标签属性 Autowire自动装配
- Spring <bean>标签属性 Autowire自动装配
- 创建Bean的三种方式 在大多数情况下,Spring容器直接通过new关键字调用构造器来创建Bean实例,而class属性指定Bean实例的实现类,但这不是实例化Bean的唯一方法。实际上,Sprin
- Spring实例解析之XML装配Bean
- Spring学习笔记05--使用构造器装配属性
- Spring系列--bean容器的实例化之构造器创建bean实例(采用dtd约束)
- Spring的《XML显式装配bean》之通过构造器注入Bean
- 使用构造器装配属性
- MVC3.0在页面上的三种Html代码输出形式
- pg_dump命令报错:administrator password认证失败
- 解决window.showModalDialog在Firefox无法支持
- 网络存储大分类
- oracle临时表的用法总结 .
- spring实例化bean以及构造器装配属性
- linux网站
- UIApplication
- 存储过程语法及实例
- 我认为接口存在的意义
- Intel虚拟化技术-从VT-x到VT-d
- event.x,event.clientX,event.offsetX区别
- 李开复唱衰互联网手机:大部分公司会失败
- WM_ERASEBKGND和WM_PAINT的深刻理解 .