Spring 声明式事务处理....XML
生活随笔
收集整理的這篇文章主要介紹了
Spring 声明式事务处理....XML
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="datasource"
??class="org.apache.commons.dbcp.BasicDataSource">
??<property name="driverClassName"
?? value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
??</property>
??<property name="url"
?? value="jdbc:sqlserver://localhost:1433;databaseName=hahademo">
??</property>
??<property name="username" value="sa"></property>
</bean>
<bean id="sessionFactory"
??class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
??<property name="dataSource">
?? <ref bean="datasource"></ref>
??</property>
??<property name="hibernateProperties">
?? <props>
????<prop key="hibernate.dialect">
???? org.hibernate.dialect.SQLServerDialect
????</prop>
?? </props>
??</property>
??<property name="mappingResources">
?? <list>
????<value>po/Bank.hbm.xml</value>
?? </list>
??</property>
</bean>
<bean name="/bank" class="action.BankAction">
??<property name="bankBiz">
?? <ref bean="bankbiz" />
??</property>
</bean>
<bean id="bankbiz" class="biz.BankBizImpl">
??<property name="commonDao">
?? <ref bean="commondao" />
??</property>
</bean>
<bean id="commondao" class="dao.CommonDaoImpl">
??<property name="sessionFactory">
?? <ref bean="sessionFactory" />
??</property>
</bean>
<bean id="transactionManager"
??class="org.springframework.orm.hibernate3.HibernateTransactionManager">
??<property name="sessionFactory">
?? <ref bean="sessionFactory" />
??</property>
</bean>
<bean id="transactionInterceptor"
??class="org.springframework.transaction.interceptor.TransactionInterceptor">
??<property name="transactionManager">
?? <ref bean="transactionManager" />
??</property>
??<property name="transactionAttributes">
?? <props>
????<prop key="a">PROPAGATION_REQUIRED</prop>
?? </props>
??</property>
</bean>
<bean id="transactionInterceptor1"
??class="org.springframework.transaction.interceptor.TransactionInterceptor">
??<property name="transactionManager">
?? <ref bean="transactionManager" />
??</property>
??<property name="transactionAttributes">
?? <props>
????<prop key="*">PROPAGATION_REQUIRED</prop>
?? </props>
??</property>
</bean>
<bean
??class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
??<property name="beanNames">
?? <list>
????<value>bankbiz</value>
?? </list>
??</property>
??<property name="interceptorNames">
?? <list>
????<value>transactionInterceptor</value>
????<value>transactionInterceptor1</value>
?? </list>
??</property>
</bean>
<!--
??<bean id="biztransactionproxy"
??class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
??<property name="transactionManager">
??<ref bean="transactionManager" />
??</property>
??<property name="target">
??<ref bean="bankbiz" />
??</property>
??<property name="transactionAttributes">
??<props>
??<prop key="*">PROPAGATION_REQUIRED</prop>
??</props>
??</property>
??</bean>
-->
</beans>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd">
<bean id="datasource"
??class="org.apache.commons.dbcp.BasicDataSource">
??<property name="driverClassName"
?? value="com.microsoft.sqlserver.jdbc.SQLServerDriver">
??</property>
??<property name="url"
?? value="jdbc:sqlserver://localhost:1433;databaseName=hahademo">
??</property>
??<property name="username" value="sa"></property>
</bean>
<bean id="sessionFactory"
??class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
??<property name="dataSource">
?? <ref bean="datasource"></ref>
??</property>
??<property name="hibernateProperties">
?? <props>
????<prop key="hibernate.dialect">
???? org.hibernate.dialect.SQLServerDialect
????</prop>
?? </props>
??</property>
??<property name="mappingResources">
?? <list>
????<value>po/Bank.hbm.xml</value>
?? </list>
??</property>
</bean>
<bean name="/bank" class="action.BankAction">
??<property name="bankBiz">
?? <ref bean="bankbiz" />
??</property>
</bean>
<bean id="bankbiz" class="biz.BankBizImpl">
??<property name="commonDao">
?? <ref bean="commondao" />
??</property>
</bean>
<bean id="commondao" class="dao.CommonDaoImpl">
??<property name="sessionFactory">
?? <ref bean="sessionFactory" />
??</property>
</bean>
<bean id="transactionManager"
??class="org.springframework.orm.hibernate3.HibernateTransactionManager">
??<property name="sessionFactory">
?? <ref bean="sessionFactory" />
??</property>
</bean>
<bean id="transactionInterceptor"
??class="org.springframework.transaction.interceptor.TransactionInterceptor">
??<property name="transactionManager">
?? <ref bean="transactionManager" />
??</property>
??<property name="transactionAttributes">
?? <props>
????<prop key="a">PROPAGATION_REQUIRED</prop>
?? </props>
??</property>
</bean>
<bean id="transactionInterceptor1"
??class="org.springframework.transaction.interceptor.TransactionInterceptor">
??<property name="transactionManager">
?? <ref bean="transactionManager" />
??</property>
??<property name="transactionAttributes">
?? <props>
????<prop key="*">PROPAGATION_REQUIRED</prop>
?? </props>
??</property>
</bean>
<bean
??class="org.springframework.aop.framework.autoproxy.BeanNameAutoProxyCreator">
??<property name="beanNames">
?? <list>
????<value>bankbiz</value>
?? </list>
??</property>
??<property name="interceptorNames">
?? <list>
????<value>transactionInterceptor</value>
????<value>transactionInterceptor1</value>
?? </list>
??</property>
</bean>
<!--
??<bean id="biztransactionproxy"
??class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
??<property name="transactionManager">
??<ref bean="transactionManager" />
??</property>
??<property name="target">
??<ref bean="bankbiz" />
??</property>
??<property name="transactionAttributes">
??<props>
??<prop key="*">PROPAGATION_REQUIRED</prop>
??</props>
??</property>
??</bean>
-->
</beans>
總結(jié)
以上是生活随笔為你收集整理的Spring 声明式事务处理....XML的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 乌鲁木齐哪里修宝来车好
- 下一篇: 1.1_SSH项目开发流程