<?xml version="1.0" encoding="UTF-8" ?>
<!--跟标签beans,里面配置一个又一个的bean子标签,每一个bean子标签都代表一个类的配置-->
<beans>
<!--id标识对象,class是类的全限定类名-->
<bean id="accountDao" class="com.lagou.edu.dao.impl.JdbcAccountDaoImpl">
<property name="ConnectionUtils" ref="connectionUtils"/>
</bean>
<!--实例化对象TransferServiceImpl-->
<bean id="transferService" class="com.lagou.edu.service.impl.TransferServiceImpl">
<!--给TransferServiceImpl中的AccountDao属性传值,TransferServiceImpl类中有setAccountDao()方法-->
<!--set+ name 之后锁定到传值的set方法了,通过反射技术可以调用该方法传入对应的值-->
<!--ref="",这里是指传入哪个值,在上面有个ID=accountDao的bean,这个bean实例化的对象
就是要传入transferService中的accountDao对象-->
<property name="AccountDao" ref="accountDao"></property>
</bean>
<!--配置新增的三个Bean-->
<bean id="connectionUtils" class="com.lagou.edu.utils.ConnectionUtils"></bean>
<!--事务管理器-->
<bean id="transactionManager" class="com.lagou.edu.utils.TransactionManager">
<property name="ConnectionUtils" ref="connectionUtils"/>
</bean>
<!--代理对象工厂-->
<bean id="proxyFactory" class="com.lagou.edu.factory.ProxyFactory">
<property name="TransactionManager" ref="transactionManager"/>
</bean>
</beans>
beans.xml代码示例
最新推荐文章于 2023-07-17 12:47:07 发布