diff --git a/src/main/java/org/applesline/desensitize/config/AutoDesensitizeConfiguration.java b/src/main/java/org/applesline/desensitize/config/AutoDesensitizeConfiguration.java index c266930..eaa61c8 100644 --- a/src/main/java/org/applesline/desensitize/config/AutoDesensitizeConfiguration.java +++ b/src/main/java/org/applesline/desensitize/config/AutoDesensitizeConfiguration.java @@ -4,6 +4,8 @@ import org.applesline.desensitize.aop.DesensitizeAdvice; import org.applesline.desensitize.executor.DesensitizeExecutor; import org.applesline.desensitize.executor.JsonPathDesensitizeExecutor; import org.applesline.desensitize.handle.DesensitizeHandlerSelector; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingClass; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; @@ -15,11 +17,13 @@ import org.springframework.context.annotation.Configuration; public class AutoDesensitizeConfiguration { @Bean + @ConditionalOnMissingBean(DesensitizeHandlerSelector.class) public DesensitizeHandlerSelector maskHandlerSelector() { return new DesensitizeHandlerSelector(); } @Bean + @ConditionalOnMissingBean(DesensitizeExecutor.class) public DesensitizeExecutor maskSensitiveExecutor(DesensitizeHandlerSelector desensitizeHandlerSelector) { return new JsonPathDesensitizeExecutor(desensitizeHandlerSelector); }