title: Spring batch with Spring boot - configuring JobRepositoryFactoryBean
body: <p>I'm new to Spring Batch with Boot. I'm having an issue with configuring jobRepositoryFactory bean with postgres as the database. 
  Below is my configuration class. </p>
  
  <pre><code>@Configuration
  @EnableBatchProcessing
  @Import(DataSourceConfiguration.class)
  public class BatchConfiguration {
  
      @Autowired
      public JobBuilderFactory jobBuilderFactory;
  
      @Autowired
      public StepBuilderFactory stepBuilderFactory;
  
      @Autowired
      private PlatformTransactionManager transactionManager;
  
      private final DataSourceConfiguration dataSourceConfiguration;
  
  public BatchConfiguration(DataSourceConfiguration dataSourceConfiguration) {
      this.dataSourceConfiguration = dataSourceConfiguration;
  }
  
  
      @Bean
      public ElasticReader elasticReader()  {
          return new ElasticReader();
      }
  
  @Bean
  public JobRepository jobRepositoryFactoryBean() throws Exception {
      JobRepositoryFactoryBean fb = new JobRepositoryFactoryBean();
      fb.setDatabaseType("postgres");
      fb.setDataSource(dataSourceConfiguration.dataSource());
      fb.setTransactionManager(transactionManager);
      return fb.getObject();
  }
  
  @Bean
  public PlatformTransactionManager platformTransactionManager() {
      return transactionManager;
  }
  
      @Bean
      public StageReader stageReader(){
          return new StageReader();
      }
  
      @Bean
      public DocumentItemProcessor processor() {
          return new DocumentItemProcessor();
      }
  
      @Bean
      public ExcelWiter writer() {
          return new ExcelWiter();
      }
  
      @Bean
      public StageWriter stageWriter() {
          return new StageWriter();
      }
  
      @Bean
      public Job importUserJob() {
          return jobBuilderFactory.get("importUserJob")
                  .incrementer(new RunIdIncrementer())
                  .flow(step1())
                  .next(step2())
                  .end()
                  .build();
      }
  
  
      @Bean
      public Step step1() {
          return stepBuilderFactory.get("step1")
                  .&lt;List&lt;JsonObject&gt;,List&lt;JsonObject&gt;&gt; chunk(10)
                  .reader(stageReader())
                  .writer(stageWriter())
                  .build();
      }
  
  
      @Bean
      public Step step2() {
          return stepBuilderFactory.get("step2")
                  .&lt;List&lt;OnboardConfigVO&gt;,List&lt;ExportVO&gt;&gt; chunk(10)
                  .reader(elasticReader())
                  .processor(processor())
                  .writer(writer())
                  .build();
      }
  
  }
  </code></pre>
  
  <p>DataSourceConfiguration.class </p>
  
  <pre><code>@PropertySource("classpath:/batch-postgresql.properties")
  public class DataSourceConfiguration {
  
  @Autowired
  private Environment environment;
  
  @Autowired
  private ResourceLoader resourceLoader;
  
  @PostConstruct
  protected void initialize() {
       ResourceDatabasePopulator populator = new ResourceDatabasePopulator();
   populator.addScript(resourceLoader.getResource(environment.getProperty("bach.schema.script")));
  
  
  
      populator.setContinueOnError(true);
      DatabasePopulatorUtils.execute(populator , dataSource());
  }
  
  @Bean(destroyMethod="close")
  public DataSource dataSource() {
          BasicDataSource dataSource = new BasicDataSource();
          dataSource.setDriverClassName
         (environment.getProperty(batch.jdbc.driver");
         dataSource.setUrl(environment.getProperty("batch.jdbc.url"));
      dataSource.setUsername(environment.getProperty("batch.jdbc.user"));
  
  dataSource.setPassword(environment.getProperty("batch.jdbc.password"));
      return dataSource;
  }
  </code></pre>
  
  <p>Here is the output of Spring boot App run </p>
  
  <pre><code>Using default security password: f5cddd58-4790-427c-83b8-b6c25044db7f
  
     2017-08-09 09:36:59.589  INFO 42576 --- [           main] 
  o.s.s.web.DefaultSecurityFilterChain     : Creating filter chain: 
   OrRequestMatcher [requestMatchers=[Ant [pattern='/css/**'], Ant 
   [pattern='/js/**'], Ant [pattern='/images/**'], Ant 
   [pattern='/webjars/**'], Ant [pattern='/**/favicon.ico'], Ant 
  [pattern='/error']]], []
     2017-08-09 09:36:59.785  INFO 42576 --- [           main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 9199 (http)
    2017-08-09 09:36:59.790  INFO 42576 --- [           main] o.s.b.a.b.JobLauncherCommandLineRunner   : Running default command line with: []
    2017-08-09 09:36:59.794  INFO 42576 --- [           main] o.s.b.c.r.s.JobRepositoryFactoryBean     : No database type set, using meta 
     data indicating: POSTGRES
    2017-08-09 09:36:59.798  INFO 42576 --- [           main] 
      o.s.b.c.l.support.SimpleJobLauncher      : No TaskExecutor has been set, 
      defaulting to synchronous executor.
  </code></pre>
  
  <p>I have configured the beans in my configuration class. What am I missing here? </p>