xxl-job

applicationcontext-xxl-job-admin.xml 3.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans xmlns="http://www.springframework.org/schema/beans"
  3. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  4. xmlns:tx="http://www.springframework.org/schema/tx"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
  7. http://www.springframework.org/schema/tx
  8. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
  9. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  10. <property name="fileEncoding" value="utf-8" />
  11. <property name="locations">
  12. <list>
  13. <value>classpath*:xxl-job-admin.properties</value>
  14. </list>
  15. </property>
  16. </bean>
  17. <!-- ********************************* part 1 :for datasource ********************************* -->
  18. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  19. <property name="driverClass" value="${xxl.job.db.driverClass}" />
  20. <property name="jdbcUrl" value="${xxl.job.db.url}" />
  21. <property name="user" value="${xxl.job.db.user}" />
  22. <property name="password" value="${xxl.job.db.password}" />
  23. <property name="initialPoolSize" value="3" />
  24. <property name="minPoolSize" value="2" />
  25. <property name="maxPoolSize" value="10" />
  26. <property name="maxIdleTime" value="60" />
  27. <property name="acquireRetryDelay" value="1000" />
  28. <property name="acquireRetryAttempts" value="10" />
  29. <property name="preferredTestQuery" value="SELECT 1" />
  30. </bean>
  31. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  32. <property name="dataSource" ref="dataSource" />
  33. <property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
  34. </bean>
  35. <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
  36. <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
  37. <property name="basePackage" value="com.xxl.job.admin.dao" />
  38. </bean>
  39. <!-- ********************************* part 2 :for tx ********************************* -->
  40. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  41. <property name="dataSource" ref="dataSource" />
  42. </bean>
  43. <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
  44. <!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->
  45. <bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  46. <property name="dataSource" ref="dataSource" />
  47. <property name="autoStartup" value="true" /> <!--自动启动 -->
  48. <property name="startupDelay" value="20" /> <!--延时启动,应用启动成功后在启动 -->
  49. <property name="overwriteExistingJobs" value="true" /> <!--覆盖DB中JOB:true、以数据库中已经存在的为准:false -->
  50. <property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
  51. <property name="configLocation" value="classpath:quartz.properties"/>
  52. </bean>
  53. <bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
  54. <!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
  55. <property name="scheduler" ref="quartzScheduler"/>
  56. <property name="accessToken" value="${xxl.job.accessToken}" />
  57. </bean>
  58. </beans>