applicationcontext-xxl-job.xml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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:context="http://www.springframework.org/schema/context"
  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/context
  8. http://www.springframework.org/schema/context/spring-context-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-executor.properties</value>
  14. </list>
  15. </property>
  16. </bean>
  17. <!-- ********************************* 基础配置 ********************************* -->
  18. <!-- 配置01、JobHandler 扫描路径 -->
  19. <context:component-scan base-package="com.xxl.job.executor.service.jobhandler" />
  20. <!-- 配置02、执行器 -->
  21. <bean id="xxlJobExecutor" class="com.xxl.job.core.executor.XxlJobExecutor" init-method="start" destroy-method="destroy" >
  22. <!-- 执行器IP[选填],为空则自动获取 -->
  23. <property name="ip" value="${xxl.job.executor.ip}" />
  24. <!-- 执行器端口号 -->
  25. <property name="port" value="${xxl.job.executor.port}" />
  26. <property name="appName" value="${xxl.job.executor.appname}" />
  27. <!-- 执行器注册器,默认使用系统提供的 "DbRegistHelper", 推荐将其改为公共的RPC服务 -->
  28. <property name="registHelper" >
  29. <!-- DbRegistHelper, 依赖 "XXL-JOB公共数据源" -->
  30. <bean class="com.xxl.job.core.registry.impl.DbRegistHelper" >
  31. <!-- XXL-JOB公共数据源 -->
  32. <property name="dataSource" ref="xxlJobDataSource" />
  33. </bean>
  34. </property>
  35. </bean>
  36. <!-- ********************************* "GlueFactory" 配置, 仅在启动 "GLUE模式任务" 时才需要, 否则可删除 ********************************* -->
  37. <!-- 配置03、GlueFactory -->
  38. <bean id="glueFactory" class="com.xxl.job.core.glue.GlueFactory">
  39. <!-- GLUE任务示例缓存失效时间, 单位/ms -->
  40. <property name="cacheTimeout" value="${xxl.job.glue.cache.time}" />
  41. <!-- GLUE源码加载器,默认使用系统提供的 "DbGlueLoader", 推荐将其改为公共的RPC服务 -->
  42. <property name="glueLoader" >
  43. <!-- DbGlueLoader, 依赖 "XXL-JOB公共数据源" -->
  44. <bean class="com.xxl.job.core.glue.loader.impl.DbGlueLoader" >
  45. <!-- XXL-JOB公共数据源 -->
  46. <property name="dataSource" ref="xxlJobDataSource" />
  47. </bean>
  48. </property>
  49. </bean>
  50. <!-- ********************************* "XXL-JOB公共数据源" 配置, 仅在启动 "DbRegistHelper" 或 "DbGlueLoader" 时才需要, 否则可删除 ********************************* -->
  51. <!-- 配置04、XXL-JOB公共数据源 -->
  52. <bean id="xxlJobDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close">
  53. <property name="driverClass" value="${xxl.job.db.driverClass}" />
  54. <property name="jdbcUrl" value="${xxl.job.db.url}" />
  55. <property name="user" value="${xxl.job.db.user}" />
  56. <property name="password" value="${xxl.job.db.password}" />
  57. <property name="initialPoolSize" value="3" />
  58. <property name="minPoolSize" value="2" />
  59. <property name="maxPoolSize" value="10" />
  60. <property name="maxIdleTime" value="60" />
  61. <property name="acquireRetryDelay" value="1000" />
  62. <property name="acquireRetryAttempts" value="10" />
  63. <property name="preferredTestQuery" value="SELECT 1" />
  64. </bean>
  65. </beans>