content: package cn.datax.service.quartz.config;
  
  import com.zaxxer.hikari.HikariDataSource;
  import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
  import org.springframework.boot.autoconfigure.quartz.QuartzDataSource;
  import org.springframework.boot.context.properties.ConfigurationProperties;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.context.annotation.Primary;
  
  /**
   * 定时任务数据源配置
   */
  @Configuration
  public class DataSourceConfig {
  
      @Bean
      @Primary
      @ConfigurationProperties("spring.datasource.primary")
      public DataSourceProperties primaryDataSourceProperties() {
          return new DataSourceProperties();
      }
  
      @Bean
      @Primary
      @ConfigurationProperties("spring.datasource.primary.configuration")
      public HikariDataSource firstDataSource() {
          return primaryDataSourceProperties().initializeDataSourceBuilder()
                  .type(HikariDataSource.class).build();
      }
  
      @Bean
      @ConfigurationProperties("spring.datasource.quartz")
      public DataSourceProperties quartzDataSourceProperties() {
          return new DataSourceProperties();
      }
  
      @Bean
      @QuartzDataSource
      @ConfigurationProperties("spring.datasource.quartz.configuration")
      public HikariDataSource quartzDataSource() {
          return quartzDataSourceProperties().initializeDataSourceBuilder()
                  .type(HikariDataSource.class).build();
      }
  }
  