我正在使用Spring Batch 2.2.4和Quartz在特定时间运行一些作业。
问题是,作业总是在第一次执行代码后才运行,然后根据计划时间运行。我想停止第一次运行,并让它仅根据计划时间运行。
我的cron表达式是"0 0 0 * * ?",我还尝试了"0 0 0 1/1 * ? *",但它仍会在应用程序启动时执行一次。
如何停止应用程序启动时的第一次执行?
这是作业上下文文件:
<batch:job id="exceptionLogJob">
<batch:step id="exceptionLogReadWriteStep">
<batch:tasklet >
<batch:chunk reader="exceptionLogReader" writer="exceptionLogWriter"
commit-interval="1000" />
</batch:tasklet>
</batch:step>
</batch:job>
<!-- ======================================================= -->
<!-- READER -->
<!-- ======================================================= -->
<bean id="exceptionLogReader"
class="org.springframework.batch.item.database.JdbcCursorItemReader">
<property name="dataSource" ref="dataSource" />
<property name="sql" value="SELECT a.*,a.rowid FROM SF_EXCEPTION_LOG a WHERE DATETIME > SYSDATE - 1" />
<property name="rowMapper" ref="ExceptionLogRowMapper" />
</bean>
<!-- ======================================================= -->
<!-- Writer -->
<!-- ======================================================= -->
<bean id="exceptionLogWriter"
class="com.mobily.sf.batchprocessor.exceptionlog.ExceptionLogWriter" />
<bean id="jobDetailExceptionLog" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass"
value="com.sf.batchprocessor.commons.JobLauncherDetails" />
<property name="jobDataAsMap">
<map>
<entry key="jobName" value="exceptionLogJob" />
<entry key="jobLocator" value-ref="jobRegistry" />
<entry key="jobLauncher" value-ref="jobLauncher" />
</map>
</property>
</bean>
<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<bean id="cronTrigger"
class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="jobDetail" ref="jobDetailExceptionLog" />
<property name="cronExpression" value="0 0 0 1/1 * ? *" />
</bean>
</property>
</bean>
</beans>