Spring abstract="true" merge="true"(原文)

原文出处:https://blog.csdn.net/xuezhan032200/article/details/9041417

abstract="true"

由于设置bean定义中设置了abstract="true",所以Spring容器就不对其进行初始化。

只是在此起了模板的作用,供其他bean继承,所以父bean的属性在类体中可以不定义,直接在bean的声明中以<proerty/>声明即可。

子bean继承他后需要在提供对应的属性和set方法即可,在子bean中就可获取从父bean继承来的值.

 

 

  1.  
    <bean id="baseLocalTxProxy" abstract="true"
  2.  
    class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
  3.  
    <property name="transactionManager"
  4.  
    ref="localTransactionManager" />
  5.  
    <property name="transactionAttributes">
  6.  
    <props>
  7.  
    <prop key="add*">PROPAGATION_REQUIRED</prop>
  8.  
    <prop key="set*">PROPAGATION_REQUIRED</prop>
  9.  
    <prop key="new*">PROPAGATION_REQUIRED</prop>
  10.  
    <prop key="save*">PROPAGATION_REQUIRED</prop>
  11.  
    <prop key="remove*">PROPAGATION_REQUIRED</prop>
  12.  
    <prop key="delete*">PROPAGATION_REQUIRED</prop>
  13.  
    <prop key="update*">PROPAGATION_REQUIRED</prop>
  14.  
    <prop key="merge*">PROPAGATION_REQUIRED</prop>
  15.  
    <prop key="modify*">PROPAGATION_REQUIRED</prop>
  16.  
    <prop key="submit">PROPAGATION_REQUIRED</prop>
  17.  
    <prop key="list*">PROPAGATION_SUPPORTS,readOnly</prop>
  18.  
    <prop key="query*">PROPAGATION_SUPPORTS,readOnly</prop>
  19.  
    <prop key="search*">PROPAGATION_SUPPORTS,readOnly</prop>
  20.  
    <prop key="load*">PROPAGATION_SUPPORTS,readOnly</prop>
  21.  
    <prop key="find*">PROPAGATION_SUPPORTS,readOnly</prop>
  22.  
    <prop key="get*">PROPAGATION_SUPPORTS,readOnly</prop>
  23.  
    </props>
  24.  
    </property>
  25.  
    </bean>
  26.  
     
  27.  
    <bean id="shopPickerServiceImpl" parent="baseLocalTxProxy">
  28.  
    <property name="target">
  29.  
    <bean class="com.ibm.bpm.wle.module.maindata.biz.impl.ShopPickerServiceImpl"
  30.  
    autowire="byName">
  31.  
    <property name="shopPickerDao" ref="shopPickerDaoImpl"></property>
  32.  
    </bean>
  33.  
    </property>
  34.  
    <property name="transactionAttributes">
  35.  
    <props merge="true">
  36.  
    <prop key="save*">PROPAGATION_SUPPORTS,readOnly</prop>
  37.  
    <prop key="list*">readOnly</prop>
  38.  
    </props>
  39.  
    </property>
  40.  
    </bean>


merge="true"

 

子bean中<prop key="save*">PROPAGATION_SUPPORTS,readOnly</prop>和父bean中的save*相同 那么

子bean会覆盖父bean 的save*.

posted @ 2018-07-14 17:18  青青子衿J  阅读(570)  评论(0)    收藏  举报