|
@@ -0,0 +1,56 @@
|
|
|
|
|
+package com.mrxu.framework.stater.xxl.config;
|
|
|
|
|
+
|
|
|
|
|
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
|
|
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
|
|
|
|
+import org.springframework.cloud.commons.util.InetUtils;
|
|
|
|
|
+import org.springframework.context.annotation.Bean;
|
|
|
|
|
+import org.springframework.context.annotation.Configuration;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 功能概要:[] <br>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author zzt
|
|
|
|
|
+ * @date 2021/11/19
|
|
|
|
|
+ */
|
|
|
|
|
+@Configuration
|
|
|
|
|
+@ConditionalOnProperty({"xxl.job.admin.addresses"})
|
|
|
|
|
+public class XxlJobConfig {
|
|
|
|
|
+ @Value("${xxl.job.admin.addresses}")
|
|
|
|
|
+ private String adminAddresses;
|
|
|
|
|
+ @Value("${xxl.job.accessToken:#{null}}")
|
|
|
|
|
+ private String accessToken;
|
|
|
|
|
+ @Value("${xxl.job.executor.appname}")
|
|
|
|
|
+ private String appname;
|
|
|
|
|
+ @Value("${xxl.job.executor.ip:#{null}}")
|
|
|
|
|
+ private String ip;
|
|
|
|
|
+ @Value("${xxl.job.executor.port:9999}")
|
|
|
|
|
+ private int port;
|
|
|
|
|
+ @Value("${xxl.job.executor.logpath:#{null}}")
|
|
|
|
|
+ private String logpath;
|
|
|
|
|
+ @Value("${xxl.job.executor.logretentiondays:21}")
|
|
|
|
|
+ private int logretentiondays;
|
|
|
|
|
+
|
|
|
|
|
+ public XxlJobConfig() {
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Bean
|
|
|
|
|
+ public XxlJobSpringExecutor xxlJobExecutor(InetUtils inetUtils) {
|
|
|
|
|
+ System.out.println("xxl-job-executor-spring-boot-starter config init.");
|
|
|
|
|
+ XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
|
|
|
|
|
+ xxlJobSpringExecutor.setAdminAddresses(this.adminAddresses);
|
|
|
|
|
+ xxlJobSpringExecutor.setAppname(this.appname);
|
|
|
|
|
+ xxlJobSpringExecutor.setPort(this.port);
|
|
|
|
|
+ xxlJobSpringExecutor.setAccessToken(this.accessToken);
|
|
|
|
|
+ xxlJobSpringExecutor.setLogPath(this.logpath);
|
|
|
|
|
+ xxlJobSpringExecutor.setLogRetentionDays(this.logretentiondays);
|
|
|
|
|
+ if (StringUtils.isBlank(this.ip)) {
|
|
|
|
|
+ xxlJobSpringExecutor.setIp(inetUtils.findFirstNonLoopbackAddress().getHostAddress());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ xxlJobSpringExecutor.setIp(this.ip);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return xxlJobSpringExecutor;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|