applicationcontext-xxl-job-admin.xml 4.2 KB
Newer Older
X
xueli.xue 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
		http://www.springframework.org/schema/beans/spring-beans-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/tx 
		http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
	
	
	<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
		<property name="fileEncoding" value="utf-8" />
		<property name="locations">
			<list>
				<value>classpath*:xxl-job-admin.properties</value>
			</list>
		</property>
	</bean>

22 23 24
	<!-- ********************************* part 1 :for datasource ********************************* -->

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">
X
xueli.xue 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
	    <property name="driverClass" value="${xxl.job.db.driverClass}" />
	    <property name="jdbcUrl" value="${xxl.job.db.url}" />
	    <property name="user" value="${xxl.job.db.user}" />
	    <property name="password" value="${xxl.job.db.password}" />
	    <property name="initialPoolSize" value="3" />  
	    <property name="minPoolSize" value="2" />  
	    <property name="maxPoolSize" value="10" />  
	    <property name="maxIdleTime" value="60" />
	    <property name="acquireRetryDelay" value="1000" />
	    <property name="acquireRetryAttempts" value="10" />
	    <property name="preferredTestQuery" value="SELECT 1" />
	</bean>
	
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="dataSource" ref="dataSource" />
		<property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
	</bean>
    
    <!-- scope must be "prototype" when junit -->
    <bean id="sqlSessionTemplate"  class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">  
          <constructor-arg index="0" ref="sqlSessionFactory" />  
    </bean> 
    
48 49
	<!-- ********************************* part 2 :for tx ********************************* -->

X
xueli.xue 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
    <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>
      
	<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
	
	<tx:advice id="txAdvice" transaction-manager="transactionManager">
		<tx:attributes>
			<tx:method name="detail*" propagation="SUPPORTS" />
			<tx:method name="visit*" propagation="SUPPORTS" />
			<tx:method name="get*" propagation="SUPPORTS" />
			<tx:method name="find*" propagation="SUPPORTS" />
			<tx:method name="check*" propagation="SUPPORTS" />
			<tx:method name="list*" propagation="SUPPORTS" />
			<tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
		</tx:attributes>
	</tx:advice>

	<aop:config>
		<aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
		<aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
	</aop:config>

73 74
	<!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->

X
xueli.xue 已提交
75 76
	<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="dataSource" ref="dataSource" />
X
xueli.xue 已提交
77 78 79
		<property name="autoStartup" value="true" />			<!--自动启动 -->
		<property name="startupDelay" value="20" />				<!--延时启动,应用启动成功后在启动 -->
		<property name="overwriteExistingJobs" value="true" />	<!--覆盖DB中JOB:true、以数据库中已经存在的为准:false -->
X
xueli.xue 已提交
80 81 82 83 84 85 86 87 88
		<property name="applicationContextSchedulerContextKey"  value="applicationContextKey" />
		<property name="configLocation" value="classpath:quartz.properties"/>
	</bean>

	<bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
		<!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
		<property name="scheduler" ref="quartzScheduler"/>
	</bean>
	
X
init  
xueli.xue 已提交
89
</beans>