相关数据表:
quartz-all-1.8.6.jar 包中的 quartz-1.8.6\docs\dbTables\ tables_oracle.sql
相关包如下
1、 com.springsource.commonj-sources-1.1.0.jar
是源码只能利用解压后放到项目中相关类如下
2、 apache-velocity-velocity-1.5.jar,jasperreports-4.0.1.zip(压缩包下的jasperreports-4.0.1.jar)
这两个包与spring-context-support-3.1.4.RELEASE.jar 有关联,经比对源码,无以上jar包,相关类报错。
加上以上两包为好
3、application-jobconfig.xml配置如下
<?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" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:context="http://www.springframework.org/schema/context" xmlns:cache="http://www.springframework.org/schema/cache"
xmlns:task="http://www.springframework.org/schema/task"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.1.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/jdbc http://www.springframework.org/schema/jdbc/spring-jdbc-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.1.xsd
http://www.springframework.org/schema/cache http://www.springframework.org/schema/cache/spring-cache-3.1.xsd
">
<!-- 定时批量压缩图片 -->
<bean id="imageComp" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="com.base.task.TimerCompressPictures"/>
<!--
<property name="jobDataAsMap">
<map>
非spring管理的service放到这里,就可以注入进去
<description>jobDataAsMap</description>
key 属性值,value 对应的bean
<entry key="uploader" value-ref="uploader" />
</map>
</property>
-->
</bean>
<bean id="imageCompTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="imageComp"/>
<property name="cronExpression" value="0/15 * * * * ?" />
</bean>
<!-- 定时批量压缩图片 -->
<bean id="quartzScheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<!-- 在配置文件中配置 -->
<property name="dataSource" ref="myDataSource"/>
<property name="schedulerContextAsMap">
<map>
<!-- spring 管理的service需要放到这里,才能够注入成功 -->
<description>schedulerContextAsMap</description>
<entry key ="sps" value-ref="sysParaServiceImpl"/>
</map>
</property>
<property name="applicationContextSchedulerContextKey" value="applicationContextKey"/>
<property name="configLocation" value="classpath:quartz.properties"/>
<!--这个是必须的,QuartzScheduler 延时启动,应用启动完后 QuartzScheduler 再启动 -->
<property name="startupDelay" value="30"/>
<!-- 这个是可选,QuartzScheduler 启动时更新己存在的Job,
这样就不用每次修改targetObject后删除qrtz_job_details表对应记录了-->
<property name="overwriteExistingJobs" value="true"/>
<property name="triggers">
<list>
<ref bean="imageCompTrigger"/>
</list>
</property>
</bean>
</beans>
4、quartz.properties配置如下
#============================================================================
# Configure Main Scheduler Properties
#============================================================================
org.quartz.scheduler.instanceName = DefaultQuartzScheduler
org.quartz.scheduler.rmi.export = false
org.quartz.scheduler.rmi.proxy = false
org.quartz.scheduler.wrapJobExecutionInUserTransaction = false
#============================================================================
# Configure ThreadPool 配置数据库连接池
#============================================================================
org.quartz.threadPool.class = org.quartz.simpl.SimpleThreadPool
org.quartz.threadPool.threadCount = 10
org.quartz.threadPool.threadPriority = 5
org.quartz.threadPool.threadsInheritContextClassLoaderOfInitializingThread = true
#============================================================================
# Configure JobStore 配置做业存储方式
#============================================================================
#相当于扫描频率,如果系统基于秒级,应培植成1000,quartz默认为分级(60000-分钟级别)
org.quartz.jobStore.misfireThreshold = 60000
#在这里自己控制事务
#org.quartz.jobStore.class = org.quartz.simpl.RAMJobStore
org.quartz.jobStore.class = org.quartz.impl.jdbcjobstore.JobStoreTX
#org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.HSQLDBDelegate
org.quartz.jobStore.driverDelegateClass=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
#org.quartz.jobStore.useProperties = true
org.quartz.jobStore.tablePrefix = QRTZ_
org.quartz.jobStore.isClustered = false
org.quartz.jobStore.maxMisfiresToHandleAtATime=1
#org.quartz.jobStore.dataSource = myOracle
#org.quartz.dataSource.myOracle.driver =oracle.jdbc.driver.OracleDriver
#org.quartz.dataSource.myOracle.URL =jdbc:oracle:thin:@***.***.***.***:orcl
#org.quartz.dataSource.myOracle.user =****
#org.quartz.dataSource.myOracle.password =****
#org.quartz.dataSource.myOracle.maxConnections =5
5、类如下QuartzJobBean 子类案例