applicationcontext-xxl-job-admin.xml 3.4 KB
Newer Older
X
xueli.xue 已提交
1 2 3
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4
	   xmlns:tx="http://www.springframework.org/schema/tx"
X
xueli.xue 已提交
5
	   xsi:schemaLocation="http://www.springframework.org/schema/beans
6
		http://www.springframework.org/schema/beans/spring-beans.xsd
X
xueli.xue 已提交
7
		http://www.springframework.org/schema/tx 
8
		http://www.springframework.org/schema/tx/spring-tx.xsd">
X
xueli.xue 已提交
9 10 11 12 13 14 15 16 17 18 19
	
	
	<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>

20 21 22
	<!-- ********************************* part 1 :for datasource ********************************* -->

	<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"  destroy-method="close">
X
xueli.xue 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
	    <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>
40 41 42 43 44

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
		<property name="basePackage" value="com.xxl.job.admin.dao" />
	</bean>
X
xueli.xue 已提交
45
    
46 47
	<!-- ********************************* part 2 :for tx ********************************* -->

X
xueli.xue 已提交
48 49 50 51 52 53
    <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"/>

54 55
	<!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->

X
xueli.xue 已提交
56 57
	<bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
		<property name="dataSource" ref="dataSource" />
X
xueli.xue 已提交
58 59 60
		<property name="autoStartup" value="true" />			<!--自动启动 -->
		<property name="startupDelay" value="20" />				<!--延时启动,应用启动成功后在启动 -->
		<property name="overwriteExistingJobs" value="true" />	<!--覆盖DB中JOB:true、以数据库中已经存在的为准:false -->
X
xueli.xue 已提交
61 62 63 64 65 66 67
		<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"/>
68
		<property name="accessToken" value="${xxl.job.accessToken}" />
X
xueli.xue 已提交
69 70
	</bean>
	
X
init  
xueli.xue 已提交
71
</beans>