1、基本知识

1.beans.xml中bean的调用,可以采用

①ref的注入方式:

<bean id="daoTest" class="com.test"></bean>

<bean id="service" class="com.service" ref="daoTest"></bean>

特点:写起来麻烦,但可以供多个类使用;

②采用内部bean的方式

<bean id="service" class="com.service">

       <property name="daoTest">

       <bean class="com.test">

       </porperty>

</bean>

特点:写起来简单,但是不可供多个bean使用;

 



原文地址:https://www.cnblogs.com/zmpandzmp/p/3648809.html