diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
index 225d8b47a..7f74d71d5 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/pom.xml
@@ -49,12 +49,14 @@
cn.iocoder.cloud
yudao-spring-boot-starter-job
+ true
cn.iocoder.cloud
yudao-spring-boot-starter-mq
+ true
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
index 41cad1ed3..fe9adca83 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
@@ -21,6 +21,7 @@ import com.xxl.job.core.executor.XxlJobExecutor;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
@@ -90,44 +91,10 @@ public class YudaoTenantAutoConfiguration {
return registrationBean;
}
- // ========== MQ ==========
-
- @Bean
- @GlobalChannelInterceptor // 必须添加在方法上,否则无法生效
- public TenantChannelInterceptor tenantChannelInterceptor() {
- return new TenantChannelInterceptor();
- }
-
- @Bean
- public FunctionAroundWrapper functionAroundWrapper() {
- return new TenantFunctionAroundWrapper();
- }
-
// ========== Job ==========
@Bean
- public BeanPostProcessor jobHandlerBeanPostProcessor(TenantFrameworkService tenantFrameworkService) {
- return new BeanPostProcessor() {
-
- @Override
- public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
- if (!(bean instanceof XxlJobExecutor)) {
- return bean;
- }
-// // 有 TenantJob 注解的情况下,才会进行处理
-// if (!AnnotationUtil.hasAnnotation(bean.getClass(), TenantJob.class)) {
-// return bean;
-// }
-//
-// // 使用 TenantJobHandlerDecorator 装饰
-// return new TenantJobHandlerDecorator(tenantFrameworkService, (JobHandler) bean);
- return bean;
- }
-
- };
- }
-
- @Bean
+ @ConditionalOnClass(name = "com.xxl.job.core.handler.annotation.XxlJob")
public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) {
return new TenantJobAspect(tenantFrameworkService);
}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantMQAutoConfiguration.java b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantMQAutoConfiguration.java
new file mode 100644
index 000000000..da0640bcc
--- /dev/null
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantMQAutoConfiguration.java
@@ -0,0 +1,57 @@
+package cn.iocoder.yudao.framework.tenant.config;
+
+import cn.iocoder.yudao.framework.common.enums.WebFilterOrderEnum;
+import cn.iocoder.yudao.framework.mybatis.core.util.MyBatisUtils;
+import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnoreAspect;
+import cn.iocoder.yudao.framework.tenant.core.db.TenantDatabaseInterceptor;
+import cn.iocoder.yudao.framework.tenant.core.job.TenantJobAspect;
+import cn.iocoder.yudao.framework.tenant.core.mq.TenantChannelInterceptor;
+import cn.iocoder.yudao.framework.tenant.core.mq.TenantFunctionAroundWrapper;
+import cn.iocoder.yudao.framework.tenant.core.redis.TenantRedisCacheManager;
+import cn.iocoder.yudao.framework.tenant.core.security.TenantSecurityWebFilter;
+import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkService;
+import cn.iocoder.yudao.framework.tenant.core.service.TenantFrameworkServiceImpl;
+import cn.iocoder.yudao.framework.tenant.core.web.TenantContextWebFilter;
+import cn.iocoder.yudao.framework.web.config.WebProperties;
+import cn.iocoder.yudao.framework.web.core.handler.GlobalExceptionHandler;
+import cn.iocoder.yudao.module.system.api.tenant.TenantApi;
+import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
+import com.baomidou.mybatisplus.extension.plugins.inner.TenantLineInnerInterceptor;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
+import org.springframework.boot.web.servlet.FilterRegistrationBean;
+import org.springframework.cloud.function.context.catalog.FunctionAroundWrapper;
+import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Primary;
+import org.springframework.data.redis.cache.RedisCacheConfiguration;
+import org.springframework.data.redis.cache.RedisCacheManager;
+import org.springframework.data.redis.cache.RedisCacheWriter;
+import org.springframework.data.redis.connection.RedisConnectionFactory;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.integration.config.GlobalChannelInterceptor;
+
+import java.util.Objects;
+
+@AutoConfiguration
+@ConditionalOnProperty(prefix = "yudao.tenant", value = "enable", matchIfMissing = true) // 允许使用 yudao.tenant.enable=false 禁用多租户
+@ConditionalOnClass(name = {
+ "org.springframework.messaging.support.ChannelInterceptor",
+ "org.springframework.cloud.function.context.catalog.FunctionAroundWrapper"
+})
+@EnableConfigurationProperties(TenantProperties.class)
+public class YudaoTenantMQAutoConfiguration {
+
+ @Bean
+ @GlobalChannelInterceptor // 必须添加在方法上,否则无法生效
+ public TenantChannelInterceptor tenantChannelInterceptor() {
+ return new TenantChannelInterceptor();
+ }
+
+ @Bean
+ public FunctionAroundWrapper functionAroundWrapper() {
+ return new TenantFunctionAroundWrapper();
+ }
+
+}
diff --git a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
index 26f472e4d..1a18bae89 100644
--- a/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
+++ b/yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -1,2 +1,3 @@
cn.iocoder.yudao.framework.tenant.config.YudaoTenantRpcAutoConfiguration
cn.iocoder.yudao.framework.tenant.config.YudaoTenantAutoConfiguration
+cn.iocoder.yudao.framework.tenant.config.YudaoTenantMQAutoConfiguration