diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 1bb05e20..6ea57a27 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -17,6 +17,7 @@
ruoyi-common-doc
ruoyi-common-excel
ruoyi-common-idempotent
+ ruoyi-common-job
ruoyi-common-log
ruoyi-common-mail
ruoyi-common-mybatis
diff --git a/ruoyi-common/ruoyi-common-bom/pom.xml b/ruoyi-common/ruoyi-common-bom/pom.xml
index ef001692..49c859df 100644
--- a/ruoyi-common/ruoyi-common-bom/pom.xml
+++ b/ruoyi-common/ruoyi-common-bom/pom.xml
@@ -54,6 +54,13 @@
${revision}
+
+
+ com.ruoyi
+ ruoyi-common-job
+ ${revision}
+
+
com.ruoyi
diff --git a/ruoyi-common/ruoyi-common-job/pom.xml b/ruoyi-common/ruoyi-common-job/pom.xml
new file mode 100644
index 00000000..ea2b6d03
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-job/pom.xml
@@ -0,0 +1,43 @@
+
+
+
+ com.ruoyi
+ ruoyi-common
+ ${revision}
+ ../pom.xml
+
+ 4.0.0
+
+ ruoyi-common-job
+
+
+ ruoyi-common-job 定时任务
+
+
+
+
+
+ org.springframework.boot
+ spring-boot-autoconfigure
+
+
+
+
+ com.xuxueli
+ xxl-job-core
+
+
+
+ org.projectlombok
+ lombok
+
+
+
+ com.ruoyi
+ ruoyi-common-core
+
+
+
+
diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/XxlJobConfig.java b/ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/XxlJobConfig.java
similarity index 86%
rename from ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/XxlJobConfig.java
rename to ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/XxlJobConfig.java
index 5caada8a..34191f12 100644
--- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/XxlJobConfig.java
+++ b/ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/XxlJobConfig.java
@@ -1,13 +1,12 @@
-package com.ruoyi.job.config;
+package com.ruoyi.common.job.config;
-import com.ruoyi.job.config.properties.XxlJobProperties;
+import com.ruoyi.common.job.config.properties.XxlJobProperties;
import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
-import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
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;
/**
* xxl-job config
@@ -15,9 +14,8 @@ import org.springframework.context.annotation.Configuration;
* @author Lion Li
*/
@Slf4j
-@Configuration
+@AutoConfiguration
@EnableConfigurationProperties(XxlJobProperties.class)
-@AllArgsConstructor
@ConditionalOnProperty(prefix = "xxl.job", name = "enabled", havingValue = "true")
public class XxlJobConfig {
diff --git a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/properties/XxlJobProperties.java b/ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/properties/XxlJobProperties.java
similarity index 93%
rename from ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/properties/XxlJobProperties.java
rename to ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/properties/XxlJobProperties.java
index f2c755a1..fc89a2f3 100644
--- a/ruoyi-modules/ruoyi-job/src/main/java/com/ruoyi/job/config/properties/XxlJobProperties.java
+++ b/ruoyi-common/ruoyi-common-job/src/main/java/com/ruoyi/common/job/config/properties/XxlJobProperties.java
@@ -1,4 +1,4 @@
-package com.ruoyi.job.config.properties;
+package com.ruoyi.common.job.config.properties;
import lombok.Data;
import lombok.NoArgsConstructor;
diff --git a/ruoyi-common/ruoyi-common-job/src/main/java/com/xxl/job/core/glue/impl/SpringGlueFactory.java b/ruoyi-common/ruoyi-common-job/src/main/java/com/xxl/job/core/glue/impl/SpringGlueFactory.java
new file mode 100644
index 00000000..00cd8228
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-job/src/main/java/com/xxl/job/core/glue/impl/SpringGlueFactory.java
@@ -0,0 +1,80 @@
+package com.xxl.job.core.glue.impl;
+
+import com.xxl.job.core.executor.impl.XxlJobSpringExecutor;
+import com.xxl.job.core.glue.GlueFactory;
+import jakarta.annotation.Resource;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.core.annotation.AnnotationUtils;
+
+import java.lang.reflect.Field;
+import java.lang.reflect.Modifier;
+
+/**
+ * @author xuxueli 2018-11-01
+ */
+public class SpringGlueFactory extends GlueFactory {
+ private static Logger logger = LoggerFactory.getLogger(SpringGlueFactory.class);
+
+
+ /**
+ * inject action of spring
+ * @param instance
+ */
+ @Override
+ public void injectService(Object instance){
+ if (instance==null) {
+ return;
+ }
+
+ if (XxlJobSpringExecutor.getApplicationContext() == null) {
+ return;
+ }
+
+ Field[] fields = instance.getClass().getDeclaredFields();
+ for (Field field : fields) {
+ if (Modifier.isStatic(field.getModifiers())) {
+ continue;
+ }
+
+ Object fieldBean = null;
+ // with bean-id, bean could be found by both @Resource and @Autowired, or bean could only be found by @Autowired
+
+ if (AnnotationUtils.getAnnotation(field, Resource.class) != null) {
+ try {
+ Resource resource = AnnotationUtils.getAnnotation(field, Resource.class);
+ if (resource.name()!=null && resource.name().length()>0){
+ fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(resource.name());
+ } else {
+ fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getName());
+ }
+ } catch (Exception e) {
+ }
+ if (fieldBean==null ) {
+ fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getType());
+ }
+ } else if (AnnotationUtils.getAnnotation(field, Autowired.class) != null) {
+ Qualifier qualifier = AnnotationUtils.getAnnotation(field, Qualifier.class);
+ if (qualifier!=null && qualifier.value()!=null && qualifier.value().length()>0) {
+ fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(qualifier.value());
+ } else {
+ fieldBean = XxlJobSpringExecutor.getApplicationContext().getBean(field.getType());
+ }
+ }
+
+ if (fieldBean!=null) {
+ field.setAccessible(true);
+ try {
+ field.set(instance, fieldBean);
+ } catch (IllegalArgumentException e) {
+ logger.error(e.getMessage(), e);
+ } catch (IllegalAccessException e) {
+ logger.error(e.getMessage(), e);
+ }
+ }
+ }
+ }
+
+}
diff --git a/ruoyi-common/ruoyi-common-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/ruoyi-common/ruoyi-common-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000..dfcf8a60
--- /dev/null
+++ b/ruoyi-common/ruoyi-common-job/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.ruoyi.common.job.config.XxlJobConfig
diff --git a/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml b/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml
index afbdd416..ccf19065 100644
--- a/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml
+++ b/ruoyi-extend/ruoyi-xxl-job-admin/pom.xml
@@ -57,6 +57,11 @@
spring-boot-starter-actuator
+
+ org.springframework.boot
+ spring-boot-starter-aop
+
+
org.mybatis.spring.boot
@@ -73,10 +78,10 @@
spring-boot-admin-starter-client
-
+
- com.xuxueli
- xxl-job-core
+ com.ruoyi
+ ruoyi-common-job
diff --git a/ruoyi-modules/ruoyi-job/pom.xml b/ruoyi-modules/ruoyi-job/pom.xml
index e886a293..08ed7317 100644
--- a/ruoyi-modules/ruoyi-job/pom.xml
+++ b/ruoyi-modules/ruoyi-job/pom.xml
@@ -24,10 +24,10 @@
ruoyi-common-core
-
+
- com.xuxueli
- xxl-job-core
+ com.ruoyi
+ ruoyi-common-job