Announcement Announcement Module
No announcement yet.
Job definition using annotations Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Job definition using annotations


    I've not found any documentation or examples of defining jobs using annotations.

    Is it possible to define jobs with annotation and remove all xml configurations?

    Spring 3.0.5

  • #2
    as far I know, no (at least easily). You can use Java configuration in Spring 3.0 to create your jobs, but you'll need to know what the tags from the batch namespace are actually doing behind the scenes.


    • #3
      then we should have annotation based jobs support from the framework.


      • #4
        If you have any concrete suggestions for how this would look, please sketch something here, or contribute the code to the project on github. New feature requests can also be created at More detail would be nice.


        • #5
          Given all of the "infrastructure" that comes along with Spring Batch (repository, launch, task executor, registry, etc etc), I don't see how annotations really make things a whole lot better. You'd either need to have accept a bunch of defaults, or have a ton of annotations.

          As it stands now, most of the time, you don't even create your own job class, you just configure existing spring beans to do the work.

          Would the following make sense?

          class MyClass

          I don't think so, because then you need to relate that job to everythign else (steps, readers, writers, launchers, repositories).

          Perhaps we peel this onion with something simplers, annotations for ItemReader, ItemProcessor, and ItemWriter for people writing custom components.


          • #6
            I think the best chance of using Java to configure a job is to have a fluent builder in the framework, so user can do something like this:

            public Job myJob() {
              JobBuilder builder = JobBuilder.start(step1()).next(step2());
            Other ideas more than welcome. But fundamentally I think XML is a good form for declaring state machines (like a Job).


            • #7
              Yes. it is true that majority of jobs that we are using xml are self sufficient and we don't have to create our own jobs. As of now, I don't have any suggestions as to how the annotations look like.

              However, I will keep this in mind and will write when I encounter any scenario or good use case for it. Thank you for replying to the idea.