spring 1.2.8配置文件实例

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
<beans>
 <bean id="bbCbccfxBiz" class="com.kmr.sjcb.bb.business.BbCbccfxBiz">
   <property name="KMRPM" ref="KMRPM"></property>
 </bean>

--代理对象,运用了spring的面向切面编程,将事物控制切入到业务方法中
 <bean id="bbCbccfxBizProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
   <property name="transactionManager" ref="transactionManager"></property>
   <property name="target" ref="bbCbccfxBiz"/>
   <property name="transactionAttributes">
     <props>

--要注意的是业务接口的方法必须以符号*前面的为前缀,否则事物的管理就不起作用了

--查询不需要事物控制,但也要try...catch,以免异常情况发生。
       <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="pro*">PROPAGATION_REQUIRED,-Exception</prop>
     </props>
   </property>
 </bean>
 
 <bean id="bbCbqkfxBiz" class="com.kmr.sjcb.bb.business.BbCbqkfxBiz">
   <property name="KMRPM" ref="KMRPM"></property>
 </bean>
 <bean id="bbCbqkfxBizProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
   <property name="transactionManager" ref="transactionManager"></property>
   <property name="target" ref="bbCbqkfxBiz"/>
   <property name="transactionAttributes">
     <props>
       <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="pro*">PROPAGATION_REQUIRED,-Exception</prop>
     </props>
   </property>
 </bean>
 
 <bean id="bbTxrzfxBiz" class="com.kmr.sjcb.bb.business.BbTxrzfxBiz">
   <property name="KMRPM" ref="KMRPM"></property>
 </bean>
 <bean id="bbTxrzfxBizProxy" class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
   <property name="transactionManager" ref="transactionManager"></property>
   <property name="target" ref="bbTxrzfxBiz"/>
   <property name="transactionAttributes">
     <props>
       <prop key="insert*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="update*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="delete*">PROPAGATION_REQUIRED,-Exception</prop>
    <prop key="proc*">PROPAGATION_REQUIRED,-Exception</prop>
     </props>
   </property>
 </bean>
 
 
</beans>

你可能感兴趣的:(spring 1.2.8配置文件实例)