Announcement Announcement Module
Collapse
No announcement yet.
How can I make Job at code Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How can I make Job at code

    Hi~

    I'm using Spring Batch 2 at my project.
    In sample, Job always be registered at XML file.

    At the log, Job is FlowJob and Step is TaskletStep.
    So, I try to make Job and Step by programming.
    But there are no connection between FlowJob and TaskletStep.

    please see the blow

    TaskletStep step = new TaskletStep("hiHello");
    myHello.setMessage("Hi~~~~~~");
    step.setTasklet(myHello);

    //FlowJob job = new FlowJob("TestJob");
    //job.setFlow(new SimpleFlow("hello").????????); //how cat i make this???

    SimpleJob job = new SimpleJob("TestJob");
    job.addStep(step);

    JobParametersBuilder builder = new JobParametersBuilder();
    builder.addDate("date", new Date());

    try {
    jobLauncher.run(job, builder.toJobParameters());
    } catch (Exception e){
    e.printStackTrace();
    }

    Instead of FlowJob, I use SimpleJob. But it doesn't work. (-_-);

    Is there any solution to make a Job??

  • #2
    SimpleJob is an InitializingBean. If you call afterPropertiesSet() before you use it, it will tell you what you have missing. FlowJob is not so easy to set up by hand and I wouldn't recommend it, but if you must do it then look ta the unit tests for examples.

    In general, if you need help, please bear in mind that "it doesn't work" is not really specific enough to know what the problem is.

    Comment

    Working...
    X