Commit c9392af4948e06e67f2d802eddb1941a0b591a89
1 parent
d97b85bb
fix(tenant): 按需注册多租户 MQ 配置
将 Redis、RabbitMQ、RocketMQ 的多租户 Bean 拆到独立条件配置, 避免未引入 yudao-spring-boot-starter-mq 的模块启动时因解析 YudaoTenantAutoConfiguration 方法签名触发 NoClassDefFoundError。 Closes https://gitee.com/zhijiantianya/yudao-cloud/issues/IJTOF4
Showing
1 changed file
with
37 additions
and
14 deletions
yudao-framework/yudao-spring-boot-starter-biz-tenant/src/main/java/cn/iocoder/yudao/framework/tenant/config/YudaoTenantAutoConfiguration.java
| ... | ... | @@ -30,6 +30,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties |
| 30 | 30 | import org.springframework.boot.web.servlet.FilterRegistrationBean; |
| 31 | 31 | import org.springframework.context.ApplicationContext; |
| 32 | 32 | import org.springframework.context.annotation.Bean; |
| 33 | +import org.springframework.context.annotation.Configuration; | |
| 33 | 34 | import org.springframework.context.annotation.Primary; |
| 34 | 35 | import org.springframework.data.redis.cache.BatchStrategies; |
| 35 | 36 | import org.springframework.data.redis.cache.RedisCacheConfiguration; |
| ... | ... | @@ -155,28 +156,37 @@ public class YudaoTenantAutoConfiguration { |
| 155 | 156 | |
| 156 | 157 | // ========== MQ ========== |
| 157 | 158 | |
| 158 | - @Bean | |
| 159 | - public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() { | |
| 160 | - return new TenantRedisMessageInterceptor(); | |
| 159 | + @Configuration(proxyBeanMethods = false) | |
| 160 | + @ConditionalOnClass(name = "cn.iocoder.yudao.framework.mq.redis.core.interceptor.RedisMessageInterceptor") | |
| 161 | + public static class TenantRedisMQConfiguration { | |
| 162 | + | |
| 163 | + @Bean | |
| 164 | + public TenantRedisMessageInterceptor tenantRedisMessageInterceptor() { | |
| 165 | + return new TenantRedisMessageInterceptor(); | |
| 166 | + } | |
| 167 | + | |
| 161 | 168 | } |
| 162 | 169 | |
| 163 | - @Bean | |
| 170 | + @Configuration(proxyBeanMethods = false) | |
| 164 | 171 | @ConditionalOnClass(name = "org.springframework.amqp.rabbit.core.RabbitTemplate") |
| 165 | - public TenantRabbitMQInitializer tenantRabbitMQInitializer() { | |
| 166 | - return new TenantRabbitMQInitializer(); | |
| 172 | + public static class TenantRabbitMQConfiguration { | |
| 173 | + | |
| 174 | + @Bean | |
| 175 | + public TenantRabbitMQInitializer tenantRabbitMQInitializer() { | |
| 176 | + return new TenantRabbitMQInitializer(); | |
| 177 | + } | |
| 178 | + | |
| 167 | 179 | } |
| 168 | 180 | |
| 169 | - @Bean | |
| 181 | + @Configuration(proxyBeanMethods = false) | |
| 170 | 182 | @ConditionalOnClass(name = "org.apache.rocketmq.spring.core.RocketMQTemplate") |
| 171 | - public TenantRocketMQInitializer tenantRocketMQInitializer() { | |
| 172 | - return new TenantRocketMQInitializer(); | |
| 173 | - } | |
| 183 | + public static class TenantRocketMQConfiguration { | |
| 174 | 184 | |
| 175 | - // ========== Job ========== | |
| 185 | + @Bean | |
| 186 | + public TenantRocketMQInitializer tenantRocketMQInitializer() { | |
| 187 | + return new TenantRocketMQInitializer(); | |
| 188 | + } | |
| 176 | 189 | |
| 177 | - @Bean | |
| 178 | - public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) { | |
| 179 | - return new TenantJobAspect(tenantFrameworkService); | |
| 180 | 190 | } |
| 181 | 191 | |
| 182 | 192 | // ========== Redis ========== |
| ... | ... | @@ -200,4 +210,17 @@ public class YudaoTenantAutoConfiguration { |
| 200 | 210 | return cacheManager; |
| 201 | 211 | } |
| 202 | 212 | |
| 213 | + // ========== Job ========== | |
| 214 | + | |
| 215 | + @Configuration(proxyBeanMethods = false) | |
| 216 | + @ConditionalOnClass(name = "com.xxl.job.core.context.XxlJobContext") | |
| 217 | + public static class TenantJobConfiguration { | |
| 218 | + | |
| 219 | + @Bean | |
| 220 | + public TenantJobAspect tenantJobAspect(TenantFrameworkService tenantFrameworkService) { | |
| 221 | + return new TenantJobAspect(tenantFrameworkService); | |
| 222 | + } | |
| 223 | + | |
| 224 | + } | |
| 225 | + | |
| 203 | 226 | } | ... | ... |