title: What is the function of JobBuilderFactory.get(job).incrementer(RunIdIncrementer)?
body: <p>I'm developing a Spring-Batch project using Spring-Boot and everything is going along nicely. I've done a few spring-batch examples (including some from spring.io), but I'm not sure what some of the stuff does, and "it just works" doesn't satiate me.</p>
  
  <p>My spring boot main class implements <code>CommandLineRunner</code> and for this particular job the initial set up looked like </p>
  
  <pre><code>@Bean
  public Job myJob(JobExecutionListenerSupport listener) {
      return myJobBuilderFactory.get(JOB)
              .listener(listener)
              .start(myStep())
              .build();
  }
  </code></pre>
  
  <p>Which caused </p>
  
  <pre><code>java.lang.IllegalStateException: Failed to execute CommandLineRunner
      at org.springframework.boot.SpringApplication.callRunner(SpringApplication.java:809) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.springframework.boot.SpringApplication.callRunners(SpringApplication.java:790) ~[spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.springframework.boot.SpringApplication.afterRefresh(SpringApplication.java:777) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:308) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1191) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.springframework.boot.SpringApplication.run(SpringApplication.java:1180) [spring-boot-1.3.2.RELEASE.jar:1.3.2.RELEASE]
      at org.bjc.providermodel.maintenance.MaintenanceApplication.main(MaintenanceApplication.java:20) [classes/:?]
  Caused by: org.springframework.batch.core.repository.JobExecutionAlreadyRunningException: A job execution for this job is already running: JobInstance: id=99, version=0, Job=[myJob]
  </code></pre>
  
  <p>Why does changing the above bean to</p>
  
  <pre><code>@Bean
  public Job myJob(JobExecutionListenerSupport listener) {
      return myJobBuilderFactory.get(JOB)
              .incrementer(new RunIdIncrementer())
              .listener(listener)
              .start(myStep())
              .build();
  }
  </code></pre>
  
  <p>Make everything go smoothly? I attempted to read up on the doc for <code>RunIdIncrementer</code> and also read up a little <a href="http://docs.spring.io/spring-batch/apidocs/org/springframework/batch/core/launch/support/CommandLineJobRunner.html" rel="noreferrer">here</a>. From what I can tell it needs this incrementer to keep track of a particular set of jobs that are running to do "stuff", but not sure what stuff is exactly. The Spring-Boot abstraction is making it hard for me to know what's going on here</p>