spring 事务配置

<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:util="http://www.springframework.org/schema/util"
	xmlns:p="http://www.springframework.org/schema/p" xmlns:tx="http://www.springframework.org/schema/tx"
	xmlns:oxm="http://www.springframework.org/schema/oxm" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:context="http://www.springframework.org/schema/context"
	xsi:schemaLocation="
	http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
	http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
	http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util.xsd
	http://www.springframework.org/schema/oxm http://www.springframework.org/schema/oxm/spring-oxm-3.0.xsd
    http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
    http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"
	default-init-method="init" default-destroy-method="destroy" default-autowire="byName">
	
	
	<!--配置数据源 -->
     <!-- 读取jdbc.properties配置文件 -->
     <context:property-placeholder location="classpath:jdbc.properties" />
    
      <!--配置数据源 -->
     <bean id="dataSource" class="org.logicalcobwebs.proxool.ProxoolDataSource">  
		<property name="driver" value="${db-0-driver}" />  
		<property name="driverUrl" value="${db-0-driverUrl}" />  
		<property name="user" value="${db-0-user}"/>
		<property name="password" value="${db-0-password}"/>  
		<property name="alias" value="${db-0-alias}"/>  
		<property name="maximumActiveTime" value="${db-0-maximumActiveTime}"/>  
		<property name="prototypeCount" value="${db-0-prototypeCount}"/>  
		<property name="maximumConnectionCount" value="${db-0-maximumConnectionCount}"/>  
		<property name="minimumConnectionCount" value="${db-0-minimumConnectionCount}"/>  
		<property name="simultaneousBuildThrottle" value="${db-0-simultaneousBuildThrottle}"/>  
		<property name="houseKeepingTestSql" value="${db-0-houseKeepingTestSql}"/>
		 
	</bean>
     

     <bean id="txManager"
         class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
         <property name="dataSource" ref="dataSource" />
     </bean>
   
   
   		<tx:advice id="txAdvice" transaction-manager="txManager">  
		    <tx:attributes>  
		        <tx:method name="add*" propagation="REQUIRED" />  
		        <tx:method name="*" propagation="REQUIRED"  rollback-for="Throwable"/>  
		    </tx:attributes>  
		</tx:advice>
		 <aop:config>
			<aop:pointcut id="allManagerMethod"   expression="execution(* net.zhima.jobs.service.*.*(..))" />  
		    <aop:advisor advice-ref="txAdvice" pointcut-ref="allManagerMethod" />
		</aop:config> 
 	
 </beans>

 就是记录一下怎么配置数据源管用。

猜你喜欢

转载自01jiangwei01.iteye.com/blog/1831402
今日推荐