663dfafb032dadde9a16454e6b2de760dc64b7be.svn-base 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. package org.jeecg.boot.starter.job.config;
  2. import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
  3. import lombok.extern.slf4j.Slf4j;
  4. import org.jeecg.boot.starter.job.prop.XxlJobProperties;
  5. import org.springframework.beans.factory.annotation.Autowired;
  6. import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
  7. import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
  8. import org.springframework.boot.context.properties.EnableConfigurationProperties;
  9. import org.springframework.context.annotation.Bean;
  10. import org.springframework.context.annotation.Configuration;
  11. /**
  12. * 定时任务配置
  13. *
  14. * @author jeecg
  15. */
  16. @Slf4j
  17. @Configuration
  18. @EnableConfigurationProperties(value = XxlJobProperties.class)
  19. @ConditionalOnProperty(value = "jeecg.xxljob.enabled", havingValue = "true", matchIfMissing = true)
  20. public class XxlJobConfiguration {
  21. @Autowired
  22. private XxlJobProperties xxlJobProperties;
  23. //@Bean(initMethod = "start", destroyMethod = "destroy")
  24. @Bean
  25. @ConditionalOnClass()
  26. public XxlJobSpringExecutor xxlJobExecutor() {
  27. log.info(">>>>>>>>>>> xxl-job config init.");
  28. //log.info(">>>> ip="+xxlJobProperties.getIp()+",Port="+xxlJobProperties.getPort()+",address="+xxlJobProperties.getAdminAddresses());
  29. XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
  30. xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdminAddresses());
  31. xxlJobSpringExecutor.setAppname(xxlJobProperties.getAppname());
  32. //update-begin--Author:scott -- Date:20210305 -- for:system服务和demo服务有办法同时使用xxl-job吗 #2313---
  33. //xxlJobSpringExecutor.setIp(xxlJobProperties.getIp());
  34. //xxlJobSpringExecutor.setPort(xxlJobProperties.getPort());
  35. //update-end--Author:scott -- Date:20210305 -- for:system服务和demo服务有办法同时使用xxl-job吗 #2313---
  36. xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
  37. xxlJobSpringExecutor.setLogPath(xxlJobProperties.getLogPath());
  38. xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getLogRetentionDays());
  39. return xxlJobSpringExecutor;
  40. }
  41. }