title: Spring Batch - Create Two Datasources and how to customized to use other properties
body: <p>I need quick guidance to create two relational datasources in Spring Boot Batch project. One is Oracle as a Source DB and Other is Postgres Target DB.
  Spring Boot V2.2.5.RELEADE</p>
  <p><strong>Spring Boot Version 2.2.5.RELEASE</strong></p>
  <p>Here I want to customized both datasources to use all properties mentioned here (<a href="http://shekup.blogspot.com/2018/05/multiple-data-sources-in-spring-batch.html#:%7E:text=Multiple%20Data%20sources%20in%20Spring%20batch,such%20as%20ETL%20batch%20job." rel="nofollow noreferrer">http://shekup.blogspot.com/2018/05/multiple-data-sources-in-spring-batch.html#:~:text=Multiple%20Data%20sources%20in%20Spring%20batch,such%20as%20ETL%20batch%20job.</a>) for both datasources</p>
  <pre><code>spring.datasource.url=jdbc:postgresql://localhost:5432/postgres?currentSchema=XXXX?useSSL=false
  spring.datasource.url=jdbc:postgresql://localhost:5432/postgres
  spring.datasource.username=postgres
  spring.datasource.password=admin
  spring.datasource.driver-class-name=org.postgresql.Driver
  
  # max no. of connections in the pool
  spring.datasource.hikari.maximum-pool-size=30
  spring.datasource.hikari.minimum-idle=20
  spring.datasource.hikari.connection-test-query=SELECT 1
  
  
  spring.jpa.database-platform=org.hibernate.dialect.PostgreSQLDialect
  spring.jpa.properties.hibernate.default_schema=YYYY
  
  
  spring.batch.initialize-schema=always
  spring.batch.table-prefix=YYYY.BATCH_
  
  ### Source oracle DS ###
  oracle.datasource.url=jdbc:oracle:thin:@//XXXX:1527/XXX
  oracle.datasource.username=XXX
  oracle.datasource.password=XXX
  oracle.datasource.driverClassName=oracle.jdbc.Oracloracleiver
  
  # max no. of connections in the pool
  oracle.spring.datasource.hikari.maximum-pool-size=30
  oracle.spring.datasource.hikari.minimum-idle=20
  oracle.spring.datasource.hikari.connection-test-query=SELECT 1
  </code></pre>
  <p>DBConfig</p>
  <pre><code>@Configuration
  public class DataSourceConfig {
      @Autowired
      private Environment env;
  
      @Primary
      @Bean(name = &quot;postgresDataSource&quot;)
      @ConfigurationProperties(&quot;spring.datasource&quot;)
      public DataSource batchDataSource() {
          return DataSourceBuilder.create().url(env.getProperty(&quot;spring.datasource.url&quot;))
                  .driverClassName(env.getProperty(&quot;spring.datasource.driver-class-name&quot;))
                  .username(env.getProperty(&quot;spring.datasource.username&quot;))
                  .password(env.getProperty(&quot;spring.datasource.password&quot;)).build();
      }
         
      @Bean(name = &quot;oracleDataSource&quot;)
      @ConfigurationProperties(&quot;oracle.datasource&quot;)
      public DataSource mysqlBatchDataSource() {
          return DataSourceBuilder.create().url(env.getProperty(&quot;oracle.datasource.url&quot;))
                  .driverClassName(env.getProperty(&quot;oracle.datasource.driver-class-name&quot;))
                  .username(env.getProperty(&quot;oracle.datasource.username&quot;))
                  .password(env.getProperty(&quot;oracle.datasource.password&quot;)).build();
      }   
  }
  </code></pre>