在石英调度程序中多次调用作业
Job is getting called multiple times in quartz scheduler
我是 运行 使用 quartz 调度程序和 cron 表达式的批处理作业,但该作业在循环中被多次调用。
这里是配置
public static void main(String[] args) {
String[] springConfig =
{
"classpath:/execs/execJob.xml"
};
ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);
}
在execJob.xml-
<import resource="classpath:/schedulers/BatchLaunch.xml" />
在BatchLaunch.xml
<import resource="classpath:/environment/springBatchDbContext.xml" />
<import resource="classpath:/environment/simpleJobEnvironment.xml" />
<import resource="classpath:/jobs/Job.xml" />
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name="triggers">
<ref bean="JobTrigger" />
</property>
<property name="jobFactory">
<bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" />
</property>
<property name="schedulerContextAsMap">
<map>
<entry key="job" value-ref="job" />
<entry key="jobLauncher" value-ref="jobLauncher"/>
<entry key="jobLocator" value-ref="jobRegistry"/>
</map>
</property>
</bean>
<bean id="JobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="JobDetail" />
<property name="cronExpression" value="JobSchedule!{receive.recon.file.schedule}" />
</bean>
<bean id="JobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.abc.scheduler.JobLauncherDetails" />
<property name="group" value="quartz-batch" />
<property name="jobDataAsMap">
<map>
<entry key="jobName" value="Job"/>
<entry key="reconTimestamp" value="JobSchedule!{receive.recon.file.schedule.timestamp}"/>
</map>
</property>
</bean>
<bean id="quartzPlaceholderProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location" value="classpath:reconCronSchedule.properties" />
<property name="placeholderPrefix" value="JobSchedule!{" />
<property name="placeholderSuffix" value="}" />
</bean>
这是 cron
receive.recon.file.schedule=* */10 * * * ?
receive.recon.file.schedule.timestamp=2014-03-01 00:00:00
下面是日志文件:
2015-02-06 11:44:27 INFO jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: com.mysql.jdbc.Driver
2015-02-06 11:44:28 INFO launch.support.SimpleJobLauncher - No TaskExecutor has been set, defaulting to synchronous executor.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-02-06 11:44:29 INFO context.support.DefaultLifecycleProcessor - Starting beans in phase 2147483647
2015-02-06 11:44:29 INFO scheduling.quartz.SchedulerFactoryBean - Starting Quartz Scheduler now
Done
2015-02-06 11:44:29 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203269076}]
2015-02-06 11:44:29 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203269075}]
2015-02-06 11:44:29 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203270003}]
2015-02-06 11:44:30 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203271002}]
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>0
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>1
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>3
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>4
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>5
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>6
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>7
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>8
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>9
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>10
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>11
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>12
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>13
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>14
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>15
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>16
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>17
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>18
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>19
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>20
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>21
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>22
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>23
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>24
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>25
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>26
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>27
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>28
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>29
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:32 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>30
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>31
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>32
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>33
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>34
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>35
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>36
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>37
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>38
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>39
2015-02-06 11:44:32 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203272001}]
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:32 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
在这里,tasklet 被一次又一次地调用。
谁能建议这里发生了什么?
我是否遗漏了任何配置或做错了什么?
我们遇到了这个问题。我们的案例是我们在 applicationContext.xml 中配置了一个 bean,但我们也使用了 :
ApplicationContext context = new ClassPathXmlApplicationContext("/config/applicationContext.xml");
所以,有两个 bean totally.So 我们的任务执行了两次。
最近,我们改变了这个:
MyBean myBean = (MyBean) BeanUtils.getBean("beanName", MyBean.class);
一切正常。
这是 BeanUtils:
public final class BeanUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public static Object getBean(String beanName) {
return applicationContext.getBean(beanName);
}
public static <T> T getBean(String beanName, Class<T> clazs) {
return clazs.cast(getBean(beanName));
}
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
BeanUtils.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}
希望这对您有所帮助。
哎呀!!!
我在做一件愚蠢的事。
一切都在 cron 表达式中,
我每秒都在安排它。
我是 运行 使用 quartz 调度程序和 cron 表达式的批处理作业,但该作业在循环中被多次调用。
这里是配置
public static void main(String[] args) {
String[] springConfig =
{
"classpath:/execs/execJob.xml"
};
ApplicationContext context = new ClassPathXmlApplicationContext(springConfig);
}
在execJob.xml-
<import resource="classpath:/schedulers/BatchLaunch.xml" />
在BatchLaunch.xml
<import resource="classpath:/environment/springBatchDbContext.xml" />
<import resource="classpath:/environment/simpleJobEnvironment.xml" />
<import resource="classpath:/jobs/Job.xml" />
<bean id="scheduler" class="org.springframework.scheduling.quartz.SchedulerFactoryBean" >
<property name="triggers">
<ref bean="JobTrigger" />
</property>
<property name="jobFactory">
<bean class="org.springframework.scheduling.quartz.SpringBeanJobFactory" />
</property>
<property name="schedulerContextAsMap">
<map>
<entry key="job" value-ref="job" />
<entry key="jobLauncher" value-ref="jobLauncher"/>
<entry key="jobLocator" value-ref="jobRegistry"/>
</map>
</property>
</bean>
<bean id="JobTrigger" class="org.springframework.scheduling.quartz.CronTriggerBean">
<property name="jobDetail" ref="JobDetail" />
<property name="cronExpression" value="JobSchedule!{receive.recon.file.schedule}" />
</bean>
<bean id="JobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass" value="com.abc.scheduler.JobLauncherDetails" />
<property name="group" value="quartz-batch" />
<property name="jobDataAsMap">
<map>
<entry key="jobName" value="Job"/>
<entry key="reconTimestamp" value="JobSchedule!{receive.recon.file.schedule.timestamp}"/>
</map>
</property>
</bean>
<bean id="quartzPlaceholderProperties"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="location" value="classpath:reconCronSchedule.properties" />
<property name="placeholderPrefix" value="JobSchedule!{" />
<property name="placeholderSuffix" value="}" />
</bean>
这是 cron
receive.recon.file.schedule=* */10 * * * ?
receive.recon.file.schedule.timestamp=2014-03-01 00:00:00
下面是日志文件:
2015-02-06 11:44:27 INFO jdbc.datasource.DriverManagerDataSource - Loaded JDBC driver: com.mysql.jdbc.Driver
2015-02-06 11:44:28 INFO launch.support.SimpleJobLauncher - No TaskExecutor has been set, defaulting to synchronous executor.
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
2015-02-06 11:44:29 INFO context.support.DefaultLifecycleProcessor - Starting beans in phase 2147483647
2015-02-06 11:44:29 INFO scheduling.quartz.SchedulerFactoryBean - Starting Quartz Scheduler now
Done
2015-02-06 11:44:29 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203269076}]
2015-02-06 11:44:29 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203269075}]
2015-02-06 11:44:29 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203270003}]
2015-02-06 11:44:30 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:30 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:30 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203271002}]
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [deleteFromLineImport]
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - Inside DeleteLineImportTasklet:::::: PC - 1
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.delLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.tasklet.DeleteLineImportTasklet - process Executed
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>0
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>1
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>3
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>4
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>5
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>6
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>7
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>8
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>9
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>10
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>11
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>12
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>13
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>14
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>15
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>16
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>17
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>18
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>19
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>20
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>21
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>22
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>23
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>24
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>25
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>26
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>27
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>28
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>29
2015-02-06 11:44:31 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:31 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
2015-02-06 11:44:31 INFO core.job.SimpleStepHandler - Executing step: [insertIntoLineImport]
2015-02-06 11:44:32 INFO reconandsettlement.writer.ReconLineWritter - Inside ReadReconDataForProcessorTasklet Tasklet ::: PC - 2
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Entry into com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>30
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>31
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>32
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>33
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>34
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>35
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>36
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>37
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>38
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Reading Record NO ==============>39
2015-02-06 11:44:32 INFO launch.support.SimpleJobLauncher - Job: [FlowJob: [name=Job]] launched with the following parameters: [{reconTimestamp=2014-03-01 00:00:00, timestamp=1423203272001}]
2015-02-06 11:44:32 INFO dao.impl.ReconDaoImpl - Exit from com.abc.reconandsettlement.dao.impl.insertLineImport()
2015-02-06 11:44:32 INFO reconandsettlement.writer.ReconLineWritter - Writting successfull
在这里,tasklet 被一次又一次地调用。 谁能建议这里发生了什么? 我是否遗漏了任何配置或做错了什么?
我们遇到了这个问题。我们的案例是我们在 applicationContext.xml 中配置了一个 bean,但我们也使用了 :
ApplicationContext context = new ClassPathXmlApplicationContext("/config/applicationContext.xml");
所以,有两个 bean totally.So 我们的任务执行了两次。 最近,我们改变了这个:
MyBean myBean = (MyBean) BeanUtils.getBean("beanName", MyBean.class);
一切正常。
这是 BeanUtils:
public final class BeanUtils implements ApplicationContextAware {
private static ApplicationContext applicationContext;
public static Object getBean(String beanName) {
return applicationContext.getBean(beanName);
}
public static <T> T getBean(String beanName, Class<T> clazs) {
return clazs.cast(getBean(beanName));
}
public void setApplicationContext(ApplicationContext applicationContext)
throws BeansException {
BeanUtils.applicationContext = applicationContext;
}
public static ApplicationContext getApplicationContext() {
return applicationContext;
}
}
希望这对您有所帮助。
哎呀!!! 我在做一件愚蠢的事。 一切都在 cron 表达式中, 我每秒都在安排它。