From 7023be10728271284e3b6c9c26b607e51df06292 Mon Sep 17 00:00:00 2001 From: Charles7c Date: Thu, 28 Dec 2023 20:13:45 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96=E8=A1=8C?= =?UTF-8?q?=E4=B8=BA=E9=AA=8C=E8=AF=81=E7=A0=81=E7=BC=93=E5=AD=98=E8=87=AA?= =?UTF-8?q?=E5=8A=A8=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../autoconfigure/BehaviorCaptchaCacheConfiguration.java | 8 +++----- continew-starter-dependencies/pom.xml | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java index 2458537f..23e22549 100644 --- a/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java +++ b/continew-starter-captcha/continew-starter-captcha-behavior/src/main/java/top/charles7c/continew/starter/captcha/behavior/autoconfigure/BehaviorCaptchaCacheConfiguration.java @@ -27,6 +27,7 @@ import lombok.extern.slf4j.Slf4j; import org.redisson.client.RedisClient; import org.springframework.boot.autoconfigure.AutoConfigureBefore; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.context.annotation.Bean; import top.charles7c.continew.starter.cache.redisson.autoconfigure.RedissonAutoConfiguration; @@ -49,11 +50,8 @@ abstract class BehaviorCaptchaCacheConfiguration { @ConditionalOnClass(RedisClient.class) @AutoConfigureBefore(RedissonAutoConfiguration.class) @ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "redis") - @NoArgsConstructor(access = AccessLevel.PRIVATE) static class Redis { - - @PostConstruct - public void postConstruct() { + static { CaptchaServiceFactory.cacheService.put(StorageType.REDIS.name().toLowerCase(), new BehaviorCaptchaCacheServiceImpl()); log.debug("[ContiNew Starter] - Auto Configuration 'Behavior-CaptchaCache-Redis' completed initialization."); } @@ -63,10 +61,10 @@ abstract class BehaviorCaptchaCacheConfiguration { * 自定义缓存实现类-自定义 */ @ConditionalOnProperty(name = "continew-starter.captcha.behavior.cache-type", havingValue = "custom") - @NoArgsConstructor(access = AccessLevel.PRIVATE) static class Custom { @Bean + @ConditionalOnMissingBean public CaptchaCacheService captchaCacheService(BehaviorCaptchaProperties properties) { return ReflectUtil.newInstance(properties.getCacheImpl()); } diff --git a/continew-starter-dependencies/pom.xml b/continew-starter-dependencies/pom.xml index 1960c6ee..afb86c10 100644 --- a/continew-starter-dependencies/pom.xml +++ b/continew-starter-dependencies/pom.xml @@ -180,7 +180,7 @@ ${x-file-storage.version} - + com.amazonaws aws-java-sdk-s3