title: Create metadata tables for Spring Batch in an embedded database
body: <p>I'm using Spring Boot autoconfigured Spring Batch setup with <code>@EnableBatchProcessing</code>. The problem is that it creates metadata tables in the main database and I don't want this behavior. I would like to save all the Spring Batch information to an embedded database.</p>
  
  <p>I've tried using the <code>spring.batch.initialize-schema=embedded</code> property and adding H2 to the classpath, overriding <code>DefaultBatchConfigurer</code> bean with the H2 data source, replacing <code>JobRepository</code> and <code>JobLauncher</code> beans but it constantly creates metadata tables in the main Oracle database. I'm using Spring Batch 3.0.8 and Spring Boot 1.5.9.</p>
  
  <p>Any help is appreciated, thank you!</p>
  
  <p><strong>UPDATE</strong>: Adding come configuration:</p>
  
  <p>H2 config:</p>
  
  <pre><code>@Bean
  public DataSource springBatchDataSource() {
      DriverManagerDataSource dataSource = new DriverManagerDataSource();
      dataSource.setDriverClassName("org.h2.Driver");
      dataSource.setUrl("jdbc:h2:mem:db;DB_CLOSE_DELAY=-1");
      dataSource.setUsername("sa");
      dataSource.setPassword("sa");
  
      return dataSource;
  }
  </code></pre>
  
  <p>Oracle:</p>
  
  <pre><code>@Bean
  @Primary
  public DataSource dataSource() throws SQLException {
      PoolDataSourceImpl dataSource = new PoolDataSourceImpl();
      dataSource.setConnectionFactoryClassName(environment.getRequiredProperty("db.driverClassName"));
      dataSource.setURL(environment.getRequiredProperty("db.url"));
      dataSource.setUser(environment.getRequiredProperty("db.username"));
      dataSource.setPassword(environment.getRequiredProperty("db.password"));
      dataSource.setFastConnectionFailoverEnabled(Boolean.valueOf(environment
              .getRequiredProperty("db.fast.connect.failover.enabled")));
      dataSource.setValidateConnectionOnBorrow(true);
      dataSource.setSQLForValidateConnection("SELECT SYSDATE FROM DUAL");
      dataSource.setONSConfiguration(environment.getRequiredProperty("db.ons.config"));
      dataSource.setInitialPoolSize(Integer.valueOf(environment.getRequiredProperty("db.initial.pool.size")));
      dataSource.setMinPoolSize(Integer.valueOf(environment.getRequiredProperty("db.min.pool.size")));
      dataSource.setMaxPoolSize(Integer.valueOf(environment.getRequiredProperty("db.max.pool.size")));
      dataSource.setAbandonedConnectionTimeout(120);
      dataSource.setInactiveConnectionTimeout(360);
      dataSource.setTimeToLiveConnectionTimeout(0);
  
      return dataSource;
  }
  </code></pre>
  
  <p>Batch configuration:</p>
  
  <pre><code>@Configuration
  @EnableBatchProcessing
  public class BatchConfigurer extends DefaultBatchConfigurer {
  
      @Override
      @Autowired
      public void setDataSource(@Qualifier("springBatchDataSource") DataSource dataSource) {
          super.setDataSource(dataSource);
      }
  
  }
  </code></pre>
  
  <p>and some properties related..</p>
  
  <pre><code>spring:
    batch:
      job.enabled: false
  </code></pre>