diff --git a/pom.xml b/pom.xml
index 30ecafc2..e188be92 100644
--- a/pom.xml
+++ b/pom.xml
@@ -14,6 +14,7 @@
xxl-job-core
xxl-job-admin
xxl-job-executor-samples
+ xxl-job-spring-boot-starter
@@ -136,7 +137,7 @@
-
+
org.sonatype.central
central-publishing-maven-plugin
diff --git a/xxl-job-spring-boot-starter/pom.xml b/xxl-job-spring-boot-starter/pom.xml
new file mode 100644
index 00000000..1a91e586
--- /dev/null
+++ b/xxl-job-spring-boot-starter/pom.xml
@@ -0,0 +1,35 @@
+
+
+ 4.0.0
+
+ com.xuxueli
+ xxl-job
+ 3.2.1-SNAPSHOT
+
+
+ com.xxl.job
+ xxl-job-spring-boot-starter
+ 3.2.1-SNAPSHOT
+ jar
+
+
+ 17
+ UTF-8
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+ 3.5.4
+ compile
+
+
+ com.xuxueli
+ xxl-job-core
+ 3.2.1-SNAPSHOT
+
+
+
\ No newline at end of file
diff --git a/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobProperties.java b/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobProperties.java
new file mode 100644
index 00000000..b26b01ff
--- /dev/null
+++ b/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobProperties.java
@@ -0,0 +1,146 @@
+package com.xxl.job.spring.boot.autoconfigure;
+
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+@ConfigurationProperties(prefix = "xxl.job")
+public class XxlJobProperties {
+ private boolean enabled;
+
+ private Admin admin;
+
+ private String accessToken;
+
+ private Executor executor;
+
+ public static class Admin {
+ private String addresses; // xxl.job.admin.addresses
+
+ public Admin() {
+ }
+
+ public Admin(String addresses) {
+ this.addresses = addresses;
+ }
+
+ public String getAddresses() {
+ return addresses;
+ }
+
+ public void setAddresses(String addresses) {
+ this.addresses = addresses;
+ }
+ }
+
+ public static class Executor {
+ private String appname; // xxl.job.executor.app-name
+ private String address;
+ private String ip;
+ private Integer port;
+ private String logPath;
+ private int logretentiondays;
+
+
+ public Executor() {
+ }
+
+ public Executor(String appname, String address, String ip, Integer port, String logPath, int logretentiondays) {
+ this.appname = appname;
+ this.address = address;
+ this.ip = ip;
+ this.port = port;
+ this.logPath = logPath;
+ this.logretentiondays = logretentiondays;
+ }
+
+ public String getAppname() {
+ return appname;
+ }
+
+ public void setAppname(String appname) {
+ this.appname = appname;
+ }
+
+ public String getAddress() {
+ return address;
+ }
+
+ public void setAddress(String address) {
+ this.address = address;
+ }
+
+ public String getIp() {
+ return ip;
+ }
+
+ public void setIp(String ip) {
+ this.ip = ip;
+ }
+
+ public Integer getPort() {
+ return port;
+ }
+
+ public void setPort(Integer port) {
+ this.port = port;
+ }
+
+ public String getLogPath() {
+ return logPath;
+ }
+
+ public void setLogPath(String logPath) {
+ this.logPath = logPath;
+ }
+
+ public int getLogretentiondays() {
+ return logretentiondays;
+ }
+
+ public void setLogretentiondays(int logretentiondays) {
+ this.logretentiondays = logretentiondays;
+ }
+ }
+
+ public XxlJobProperties() {
+ }
+
+
+ public XxlJobProperties(boolean enabled, Admin admin, String accessToken, Executor executor) {
+ this.enabled = enabled;
+ this.admin = admin;
+ this.accessToken = accessToken;
+ this.executor = executor;
+ }
+
+ public boolean isEnabled() {
+ return enabled;
+ }
+
+ public void setEnabled(boolean enabled) {
+ this.enabled = enabled;
+ }
+
+ public Admin getAdmin() {
+ return admin;
+ }
+
+ public void setAdmin(Admin admin) {
+ this.admin = admin;
+ }
+
+ public String getAccessToken() {
+ return accessToken;
+ }
+
+ public void setAccessToken(String accessToken) {
+ this.accessToken = accessToken;
+ }
+
+ public Executor getExecutor() {
+ return executor;
+ }
+
+ public void setExecutor(Executor executor) {
+ this.executor = executor;
+ }
+}
diff --git a/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobSpringBootAutoConfiguration.java b/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobSpringBootAutoConfiguration.java
new file mode 100644
index 00000000..ac09d9f6
--- /dev/null
+++ b/xxl-job-spring-boot-starter/src/main/java/com/xxl/job/spring/boot/autoconfigure/XxlJobSpringBootAutoConfiguration.java
@@ -0,0 +1,46 @@
+package com.xxl.job.spring.boot.autoconfigure;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.Objects;
+
+@Configuration
+@ConditionalOnClass({XxlJobSpringExecutor.class})
+@EnableConfigurationProperties(XxlJobProperties.class)
+@ConditionalOnProperty(name = "xxl.job.executor.enabled")
+public class XxlJobSpringBootAutoConfiguration {
+ private final XxlJobProperties xxlJobProperties;
+ private Logger logger = LoggerFactory.getLogger(XxlJobSpringBootAutoConfiguration.class);
+
+ public XxlJobSpringBootAutoConfiguration(XxlJobProperties xxlJobProperties) {
+ this.xxlJobProperties = xxlJobProperties;
+ }
+
+ @Bean
+ public XxlJobSpringExecutor xxlJobExecutor() {
+ logger.info(">>>>>>>>>>> xxl-job config init.");
+ XxlJobSpringExecutor xxlJobSpringExecutor = new XxlJobSpringExecutor();
+ xxlJobSpringExecutor.setAdminAddresses(xxlJobProperties.getAdmin().getAddresses());
+ xxlJobSpringExecutor.setAppname(xxlJobProperties.getExecutor().getAppname());
+ if (Objects.nonNull(xxlJobProperties.getExecutor().getAddress()) && !xxlJobProperties.getExecutor().getAddress().isEmpty()) {
+ xxlJobSpringExecutor.setAddress(xxlJobProperties.getExecutor().getAddress());
+ }
+ if (Objects.nonNull(xxlJobProperties.getExecutor().getIp()) && !xxlJobProperties.getExecutor().getIp().isEmpty()) {
+ xxlJobSpringExecutor.setIp(xxlJobProperties.getExecutor().getIp());
+ }
+ if (Objects.nonNull(xxlJobProperties.getExecutor().getPort()) && xxlJobProperties.getExecutor().getPort() > 0) {
+ xxlJobSpringExecutor.setPort(xxlJobProperties.getExecutor().getPort());
+ }
+ xxlJobSpringExecutor.setAccessToken(xxlJobProperties.getAccessToken());
+ xxlJobSpringExecutor.setLogPath(xxlJobProperties.getExecutor().getLogPath());
+ xxlJobSpringExecutor.setLogRetentionDays(xxlJobProperties.getExecutor().getLogretentiondays());
+ return xxlJobSpringExecutor;
+ }
+}
diff --git a/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json b/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json
new file mode 100644
index 00000000..6d4a11fa
--- /dev/null
+++ b/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -0,0 +1,77 @@
+{
+ "groups": [
+ {
+ "name": "xxl.job.enabled",
+ "type": "java.lang.Boolean",
+ "description": "xxl job enabled",
+ "defaultValue": false,
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties",
+ "sourceMethod": "isEnabled"
+ },
+ {
+ "name": "xxl.job.admin.addresses",
+ "type": "java.lang.String",
+ "description": "xxl job admin addresses",
+ "defaultValue": "http://localhost:8080/xxl-job-admin",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Admin",
+ "sourceMethod": "getAddresses"
+ },
+ {
+ "name": "xxl.job.accessToken",
+ "type": "java.lang.String",
+ "description": "xxl job access token",
+ "defaultValue": "defaultToken",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties",
+ "sourceMethod": "getAccessToken"
+ },
+ {
+ "name": "xxl.job.executor.appname",
+ "type": "java.lang.String",
+ "description": "xxl job executor app name",
+ "defaultValue": "",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getAppname"
+ },
+ {
+ "name": "xxl.job.executor.address",
+ "type": "java.lang.String",
+ "description": "xxl job executor address",
+ "defaultValue": "",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getAddress"
+ },
+ {
+ "name": "xxl.job.executor.ip",
+ "type": "java.lang.String",
+ "description": "xxl job executor ip",
+ "defaultValue": "",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getIp"
+ },
+ {
+ "name": "xxl.job.executor.port",
+ "type": "java.lang.Integer",
+ "description": "xxl job executor port",
+ "defaultValue": 0,
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getPort"
+ },
+ {
+ "name": "xxl.job.executor.logPath",
+ "type": "java.lang.String",
+ "description": "xxl job executor log path",
+ "defaultValue": "",
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getLogPath"
+ },
+ {
+ "name": "xxl.job.executor.logretentiondays",
+ "type": "java.lang.Integer",
+ "description": "xxl job executor log retention days",
+ "defaultValue": 0,
+ "sourceType": "com.xxl.job.spring.boot.autoconfigure.XxlJobProperties$Executor",
+ "sourceMethod": "getLogretentiondays"
+ }
+ ],
+ "hints": []
+}
\ No newline at end of file
diff --git a/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring.factories b/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring.factories
new file mode 100644
index 00000000..8797f59c
--- /dev/null
+++ b/xxl-job-spring-boot-starter/src/main/resources/META-INF/spring.factories
@@ -0,0 +1 @@
+org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.xxl.job.spring.boot.autoconfigure.XxlJobSpringBootAutoConfiguration
\ No newline at end of file