首页  

spring4种注入方式     所属分类 spring 浏览量 1324
set注入
构造器注入
静态工厂注入
动态工厂注入


构造器注入 <bean id="injectTestBean1" class="dyyx.inject.InjectTestBean1"> <constructor-arg value="tiger"/> <constructor-arg value="9"/> <constructor-arg ref="injectTestBean2"/> </bean> <bean id="injectTestBean11" class="dyyx.inject.InjectTestBean1"> <constructor-arg index="0" value="cat"/> <constructor-arg index="1" value="7"/> <constructor-arg index="2" ref="injectTestBean2"/> </bean> <bean id="injectTestBean2" class="dyyx.inject.InjectTestBean2"/>
set 注入 , 静态工厂 实例工厂注入 <bean id="beanFactory" class="dyyx.inject.FactoryBean"/> <bean name="factoryBean" factory-bean="beanFactory" factory-method="getBean"/> <bean name="staticFactoryBean" class="dyyx.inject.StaticFactoryBean" factory-method="getBean"/> <bean id="injectTestBean3" class="dyyx.inject.InjectTestBean3"> <property name="name" value="dog" /> <property name="age" value="8" /> <property name="factorBean" ref="factoryBean" /> <property name="staticFactorBean" ref="staticFactoryBean" /> </bean>
实例代码 https://gitee.com/dyyx/hellocode/tree/master/project/springtest/src/main/java/dyyx/inject https://gitee.com/dyyx/hellocode/blob/master/project/springtest/src/main/java/dyyx/inject/InjectTest.java https://gitee.com/dyyx/hellocode/blob/master/project/springtest/src/main/resources/inject.xml

上一篇     下一篇
mysql连接错误ERROR 2002 (HY000)解决方法

maven处理本地jar包依赖

spring bean 生命周期实例

aql输出格式和TTL设置

aerospike使用truncate删除历史数据

zookeeper常用运维命令