applicationcontext-xxl-job-admin.xml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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:aop="http://www.springframework.org/schema/aop" 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/aop
  8. http://www.springframework.org/schema/aop/spring-aop-3.0.xsd
  9. http://www.springframework.org/schema/tx
  10. http://www.springframework.org/schema/tx/spring-tx-3.0.xsd">
  11. <bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
  12. <property name="fileEncoding" value="utf-8" />
  13. <property name="locations">
  14. <list>
  15. <value>classpath*:xxl-job-admin.properties</value>
  16. </list>
  17. </property>
  18. </bean>
  19. <!-- ********************************* part 1 :for datasource ********************************* -->
  20. <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  21. <property name="driverClass" value="${xxl.job.db.driverClass}" />
  22. <property name="jdbcUrl" value="${xxl.job.db.url}" />
  23. <property name="user" value="${xxl.job.db.user}" />
  24. <property name="password" value="${xxl.job.db.password}" />
  25. <property name="initialPoolSize" value="3" />
  26. <property name="minPoolSize" value="2" />
  27. <property name="maxPoolSize" value="10" />
  28. <property name="maxIdleTime" value="60" />
  29. <property name="acquireRetryDelay" value="1000" />
  30. <property name="acquireRetryAttempts" value="10" />
  31. <property name="preferredTestQuery" value="SELECT 1" />
  32. </bean>
  33. <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
  34. <property name="dataSource" ref="dataSource" />
  35. <property name="mapperLocations" value="classpath:mybatis-mapper/*.xml"/>
  36. </bean>
  37. <!-- scope must be "prototype" when junit -->
  38. <bean id="sqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
  39. <constructor-arg index="0" ref="sqlSessionFactory" />
  40. </bean>
  41. <!-- ********************************* part 2 :for tx ********************************* -->
  42. <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
  43. <property name="dataSource" ref="dataSource" />
  44. </bean>
  45. <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
  46. <tx:advice id="txAdvice" transaction-manager="transactionManager">
  47. <tx:attributes>
  48. <tx:method name="detail*" propagation="SUPPORTS" />
  49. <tx:method name="visit*" propagation="SUPPORTS" />
  50. <tx:method name="get*" propagation="SUPPORTS" />
  51. <tx:method name="find*" propagation="SUPPORTS" />
  52. <tx:method name="check*" propagation="SUPPORTS" />
  53. <tx:method name="list*" propagation="SUPPORTS" />
  54. <tx:method name="*" propagation="REQUIRED" rollback-for="exception" />
  55. </tx:attributes>
  56. </tx:advice>
  57. <aop:config>
  58. <aop:pointcut id="txoperation" expression="execution(* com.xxl.job.admin.service.impl.*.*(..))" />
  59. <aop:advisor pointcut-ref="txoperation" advice-ref="txAdvice" />
  60. </aop:config>
  61. <!-- ********************************* part 3 :for xxl-job scheduler ********************************* -->
  62. <bean id="quartzScheduler" lazy-init="false" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
  63. <property name="dataSource" ref="dataSource" />
  64. <property name="autoStartup" value="true" /> <!--自动启动 -->
  65. <property name="startupDelay" value="20" /> <!--延时启动,应用启动成功后在启动 -->
  66. <property name="overwriteExistingJobs" value="true" /> <!--覆盖DB中JOB:true、以数据库中已经存在的为准:false -->
  67. <property name="applicationContextSchedulerContextKey" value="applicationContextKey" />
  68. <property name="configLocation" value="classpath:quartz.properties"/>
  69. </bean>
  70. <bean id="xxlJobDynamicScheduler" class="com.xxl.job.admin.core.schedule.XxlJobDynamicScheduler" init-method="init" destroy-method="destroy" >
  71. <!-- (轻易不要变更“调度器名称”, 任务创建时会绑定该“调度器名称”) -->
  72. <property name="scheduler" ref="quartzScheduler"/>
  73. <!-- 调度中心回调IP[选填],为空则自动获取 -->
  74. <property name="callBackIp" value="${xxl.job.callBackIp}"/>
  75. <!-- 调度中心回调端口号 -->
  76. <property name="callBackPort" value="${xxl.job.callBackPort}"/>
  77. </bean>
  78. </beans>