1

CommandLineJobRunnerを使用してSpringBatchジョブを実行しています。コマンドラインで-nextを使用しています。

java -Dlog4j.configuration=file:./prop/log4j.properties -Dlogfile=logfile_load_data -jar EtlLoadData.jar loaddata_etl_config.xml loaddata_etl_job -next

エラーが発生し始めました:

Job Terminated in error: A job instance already exists and is complete for parameters={run.id=10}.  If you want to run this job again, change the parameters. 

org.springframework.batch.core.repository.JobInstanceAlreadyCompleteException: A job instance already exists and is complete for parameters={run.id=10}.  If you want to run this job again, change the parameters.
    at  org.springframework.batch.core.repository.support.SimpleJobRepository.createJobExecution(SimpleJobRepository.java:122)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:597)
at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:110)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.batch.core.repository.support.AbstractJobRepositoryFactoryBean$1.invoke(AbstractJobRepositoryFactoryBean.java:168)
at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
at $Proxy14.createJobExecution(Unknown Source)
at org.springframework.batch.core.launch.support.SimpleJobLauncher.run(SimpleJobLauncher.java:111)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.start(CommandLineJobRunner.java:349)
at org.springframework.batch.core.launch.support.CommandLineJobRunner.main(CommandLineJobRunner.java:574)

-nextオプションで実行している場合、これは問題にならないはずだと思いました。何か案は?

一時的な回避策として、データベースのSpringBatchテーブルをクリーンアップしましたが、これが再び発生することは望ましくありません。

4

2 に答える 2

1

-nextオプションを認識していません。

最も簡単な方法は、現在のタイムスタンプをパラメータとしてジョブに渡すことです。そうすれば、それはユニークになり、あなたの仕事に実際に干渉することはありません。

于 2012-10-19T15:31:34.780 に答える
0

de -nextオプションを使用して、JobParametersIncrementer実装を設定する必要があります。

この例では、-> new RunIdIncrementerを使用して、次のメッセージを回避します。ジョブインスタンスは既に存在し、パラメーターが完了しています。

@Autowired
private JobBuilderFactory jobs;
...
@Bean(name=JOB_NAME)
public Job job() {        

    return jobs.get(JOB_NAME)
               .start(this.login())
               .next(this.launchDuke())
               .incrementer(new RunIdIncrementer())
               .build();
}
于 2014-12-17T19:36:10.153 に答える