XxlJobConfig.java 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. package com.tzld.piaoquan.wecom.config;
  2. import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
  3. import org.springframework.beans.factory.annotation.Value;
  4. import org.springframework.context.annotation.Bean;
  5. import org.springframework.context.annotation.Configuration;
  6. @Configuration
  7. public class XxlJobConfig {
  8. @Value("${xxl.job.admin.addresses}")
  9. private String adminAddresses;
  10. @Value("${xxl.job.accessToken}")
  11. private String accessToken;
  12. @Value("${xxl.job.executor.appname}")
  13. private String appName;
  14. @Value("${xxl.job.executor.address}")
  15. private String address;
  16. @Value("${xxl.job.executor.ip}")
  17. private String ip;
  18. @Value("${xxl.job.executor.port}")
  19. private int port;
  20. @Value("${xxl.job.executor.logpath}")
  21. private String logPath;
  22. @Value("${xxl.job.executor.logretentiondays}")
  23. private int logRetentionDays;
  24. @Bean
  25. public XxlJobSpringExecutor xxlJobExecutor() {
  26. XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
  27. xxlJobSpringExecutor.setAdminAddresses(adminAddresses);
  28. xxlJobSpringExecutor.setAppname(appName);
  29. xxlJobSpringExecutor.setAddress(address);
  30. xxlJobSpringExecutor.setIp(ip);
  31. xxlJobSpringExecutor.setPort(port);
  32. xxlJobSpringExecutor.setAccessToken(accessToken);
  33. xxlJobSpringExecutor.setLogPath(logPath);
  34. xxlJobSpringExecutor.setLogRetentionDays(logRetentionDays);
  35. return xxlJobSpringExecutor;
  36. }
  37. }