Giriş
Şu satırı dahil ederiz
import org.springframework.batch.core.JobParametersBuilder;
addX() metodları ile belirtilene değerler ItemReader, ItemWriter bean'lere parametre olarak geçilir.
addLong metodu
Şöyle yaparız
JobParameters jobParameters = new JobParametersBuilder()
.addLong("time", System.currentTimeMillis())
.toJobParameters();
addString metoduŞöyle yaparız.
JobParameters params = new JobParametersBuilder()
.addString("param1", "ABC")
.addLong("time",System.currentTimeMillis())
.toJobParameters();
toJobParameters metoduŞöyle yaparız.
@SpringBootApplication
@EnableBatchProcessing
public class XmlFileOutputApplication implements CommandLineRunner{
@Autowired
private JobLauncher jobLauncher;
@Autowired
private Job job;
public static void main(String[] args) {
SpringApplication.run(XmlFileOutputApplication.class, args);
}
@Override
public void run(String... args) throws Exception {
JobParameters jobParameters = new JobParametersBuilder()
.addString("JobId", String.valueOf(System.currentTimeMillis()))
.addDate("date", new Date())
.addLong("time",System.currentTimeMillis())
.toJobParameters();
JobExecution execution = jobLauncher.run(job, jobParameters);
System.out.println("STATUS :: "+execution.getStatus());
}
}
Hiç yorum yok:
Yorum Gönder