当前位置: 代码迷 >> J2EE >> spring配置在创建对象时,两个不同的service是不是可以用同一个daoImpl
  详细解决方案

spring配置在创建对象时,两个不同的service是不是可以用同一个daoImpl

热度:63   发布时间:2016-04-17 23:21:05.0
spring配置在创建对象时,两个不同的service是否可以用同一个daoImpl

 <bean id="Action1" class="action.xxxAction" scope="prototype">
        <property name="service1">
<ref bean="Service1" />
</property>
</bean>
<bean id="Service1" class="serviceImpl.xxxServiceImpl">
         <property name="dao1">
<ref bean="DAO1" />
</property>
</bean>
<bean id="DAO1" class="daoImpl.xxxDAOImpl">
        <property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 <bean id="Action2" class="action.xxxAction" scope="prototype">
     <property name="service2">
          <ref bean="Service2" />
    </property>
</bean>
<bean id="Service2" class="serviceImpl.xxxServiceImpl">
       <property name="dao2">
    <ref bean="DAO2" />
      </property>
 </bean>
<bean id="DAO2" class="daoImpl.xxxDAOImpl">
        <property name="jdbcTemplate">
<ref bean="jdbcTemplate" />
</property>
</bean>

两个配置中都用同一个daoImpl.xxxDAOImpl可以吗?有问题吗?会引起什么冲突之类的问题吗?
------解决思路----------------------
可以注入相同的daoImpl
------解决思路----------------------
这个可以肯定是可以的,大胆的用吧
  相关解决方案