mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-18 01:25:28 +08:00
fix PlusSmsDao 改为无条件注册(sms4j 受限处理器启动期拉取 SmsDao 会打 ERROR 日志)
应用 spec §6 预留的 fallback:从 smsDao() 移除 @ConditionalOnProperty, PlusSmsDao 重新无条件注册。原因:sms4j restricted=true 默认下,启动期 SmsBlendsInitializer 注册的 RestrictedProcessor/BlackListProcessor 等 SmsDaoAware 处理器会调 getBean(SmsDao.class),bean 被门控关闭时抛 NoSuchBeanDefinitionException → ERROR 日志 → 被 swallow 后回落默认 dao。 app 能启动但每次 boot 都打一条 ERROR(sms.enabled=false 是 dev+prod 出厂默认)。 PlusSmsDao 无条件在场 → getBean 成功 → 无异常 → 无 ERROR 日志。 软开关语义不变:发短信的真正拦截在 CaptchaController.smsCode 的 enabled 检查。 smsExceptionHandler() 仍保留 @ConditionalOnProperty(只在启用时注册)。 更新 SmsPropertiesTest:shouldAlwaysRegisterSmsDaoButOmitHandlerWhenDisabled 反映 enabled=false 时 SmsDao 在场、Handler 缺席的新语义。 Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
447f6cdd39
commit
b8a8c6a0c3
@ -47,13 +47,13 @@ public class SmsPropertiesTest {
|
||||
}
|
||||
|
||||
@Tag("dev")
|
||||
@DisplayName("sms.enabled=false 时不创建 PlusSmsDao / SmsExceptionHandler")
|
||||
@DisplayName("sms.enabled=false 时仍注册 SmsDao,但不创建 SmsExceptionHandler")
|
||||
@Test
|
||||
public void shouldNotCreateSmsBeansWhenDisabled() {
|
||||
public void shouldAlwaysRegisterSmsDaoButOmitHandlerWhenDisabled() {
|
||||
contextRunner
|
||||
.withPropertyValues("sms.enabled=false")
|
||||
.run(context -> {
|
||||
assertThat(context).doesNotHaveBean(SmsDao.class);
|
||||
assertThat(context).hasSingleBean(SmsDao.class);
|
||||
assertThat(context).doesNotHaveBean(SmsExceptionHandler.class);
|
||||
});
|
||||
}
|
||||
|
||||
@ -22,7 +22,6 @@ public class SmsAutoConfiguration {
|
||||
|
||||
@Primary
|
||||
@Bean
|
||||
@ConditionalOnProperty(prefix = "sms", name = "enabled", havingValue = "true")
|
||||
public SmsDao smsDao() {
|
||||
return new PlusSmsDao();
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user