content: package com.alibaba.tesla.appmanager.server.job;
  
  import lombok.extern.slf4j.Slf4j;
  import net.javacrumbs.shedlock.core.LockProvider;
  import net.javacrumbs.shedlock.provider.jdbctemplate.JdbcTemplateLockProvider;
  import net.javacrumbs.shedlock.spring.annotation.EnableSchedulerLock;
  import org.springframework.context.annotation.Bean;
  import org.springframework.context.annotation.Configuration;
  import org.springframework.jdbc.core.JdbcTemplate;
  import org.springframework.scheduling.annotation.EnableScheduling;
  
  import javax.sql.DataSource;
  
  /**
   * 全局 Job 配置
   *
   * @author yaoxing.gyx@alibaba-inc.com
   */
  @Slf4j
  @Configuration
  @EnableScheduling
  @EnableSchedulerLock(defaultLockAtMostFor = "10m", defaultLockAtLeastFor = "5s")
  public class JobConfig {
  
      /**
       * 提供 Lock Provider
       *
       * @param dataSource 数据源
       * @return Lock Provider
       */
      @Bean
      public LockProvider lockProvider(DataSource dataSource) {
          log.info("lock provider has registered");
          return new JdbcTemplateLockProvider(
                  JdbcTemplateLockProvider.Configuration.builder()
                          .withJdbcTemplate(new JdbcTemplate(dataSource))
                          .usingDbTime()
                          .build()
          );
      }
  }
  