标签:username color seda let gen 基本 type spring factory
<!--1.無參構造創建bean,反射,通過setter方法--> <!--默認單例bean工廠;--> <!--動態注入默認根據類型--> <bean id="stu" class="cn.kgc.kb08.spring.entity.Student" autowire="byType" scope="singleton" > <property name="age" value="18"/> <property name="gender" value="女"/> <property name="name" value="張三"/> </bean> <!--2.有參構造創建bean--> <bean id="stu2" class="cn.kgc.kb08.spring.entity.Student"> <constructor-arg index="0" value="Henry"/> <constructor-arg index="1" value="1"/> <constructor-arg index="2" value="Henry"/> </bean> <!--3.通過工廠創建bean--> <!--不能注入參數--> <bean id="stuFactory" class="cn.kgc.kb08.spring.factory.StudentFactory"/> <bean id="stu3" class="cn.kgc.kb08.spring.entity.Student" factory-bean="stuFactory" factory-method="get"/> <bean id="config" class="cn.kgc.kb08.spring.dao.SqlConfig"> <property name="driver" value=""/> <property name="url" value=""/> <property name="username" value=""/> <property name="password" value=""/><!--基本類型--> </bean> <bean id="baseDao" class="cn.kgc.kb08.spring.dao.BaseDao"> <constructor-arg index="0" ref="config"/> <!--應用類型:ref--> </bean>
标签:username color seda let gen 基本 type spring factory
原文地址:https://www.cnblogs.com/sabertobih/p/13426755.html