spring aop 事务配置

spring aop 事务配置

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:ehcache="http://www.springmodules.org/schema/ehcache"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
	http://www.springframework.org/schema/beans/spring-beans-2.5.xsd 
	http://www.springframework.org/schema/context 
	http://www.springframework.org/schema/context/spring-context-2.5.xsd 
	http://www.springframework.org/schema/aop 
	http://www.springframework.org/schema/aop/spring-aop-2.5.xsd 
	http://www.springframework.org/schema/tx 
	http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">


	<!-- 隐式注册了多个对注释进行解析处理的处理器 AutowiredAnnotationBeanPostProcessor, CommonAnnotationBeanPostProcessor,PersistenceAnnotationBeanPostProcessor, 
		RequireAnnotationBeanPostProcessor 所用jar包为lib\common-annotations.jar
	-->	
	<context:annotation-config />
	
	<!-- 自动扫描的包 ,扫描 注释了@Component,@Service,@Repository @Service用于注释业务层组件、 @Controller用于标注控制层组件、 
		@Repository用于数据访问组件即DAO组件、 @Component泛指组件 这里加载 剔除了 @Controller用于标注控制层组件 @Controller组建将在 
		spring mvc中 加载
	-->
	<context:component-scan base-package="com">	
		<context:exclude-filter type="annotation"	expression="org.springframework.stereotype.Controller" />
	</context:component-scan>	
	<!-- spring事务  -->
	<bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<tx:advice id="cftxAdvice" transaction-manager="txManager">
		<tx:attributes>
			<tx:method name="query*" propagation="REQUIRED" read-only="true" />
			<tx:method name="chaXun*" propagation="SUPPORTS" read-only="true" />
			<tx:method name="*" propagation="REQUIRED" rollback-for="Exception" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="cfPointCut"
			expression="execution(* com.newtouch..*Controller.*(..))||execution(* com.newtouch..*ServiceImp.*(..)) " />
		<aop:advisor pointcut-ref="cfPointCut" advice-ref="cftxAdvice" />
	</aop:config>
	
	<!-- 自动调度  -->
	<bean id="tongBuControllerTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
		<property name="jobDetail">
			<bean class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean" >  
			  	<property name="targetObject">  
					<bean class="com.newtouch.hlic.ui.tongbuxinxiguanli.action.TongBuController"/>
			  	</property>  
			 	<property name="targetMethod"  value="zidongdiaoduMethod" />  
			  	<property name="concurrent" value="false" />
			</bean>
		</property>
		<property name="cronExpression">
			<value>0 0 1 * * ?</value><!-- 每天凌晨1点执行一次  -->
		</property>
	</bean>
	
	<bean id="startQuartz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">      
        <property name="triggers">  
            <list>  
                <ref bean="tongBuControllerTriggerBean"/>    
            </list>  
        </property>  
    </bean>
	<!-- 自动调度   end-->
	
</beans>



你可能感兴趣的:(spring aop 事务配置)