From 00bcb50ba98ba07f651b99967ef69fce33d17036 Mon Sep 17 00:00:00 2001 From: dark <189192663@qq.com> Date: Sun, 21 Mar 2021 22:51:08 +0800 Subject: [PATCH] =?UTF-8?q?AOP=E7=9A=84=E6=B3=A8=E5=85=A5=E4=BB=8E@Compone?= =?UTF-8?q?nt=E6=94=B9=E4=B8=BA@Configuration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tracer/annotation/BizTracingAop.java | 1 - .../config/BizTracerAutoConfiguration.java | 29 +++++++++++++++++++ .../tracer/config/BizTracerProperties.java | 9 ++++++ 3 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java create mode 100644 src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerProperties.java diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java index 3b5bb5fa0..3cd1c35fb 100644 --- a/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/annotation/BizTracingAop.java @@ -16,7 +16,6 @@ import org.springframework.context.annotation.Configuration; */ @Aspect @Slf4j -@Configuration public class BizTracingAop { @Around(value = "@annotation(bizTracing)") diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java new file mode 100644 index 000000000..3b63b9c1a --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerAutoConfiguration.java @@ -0,0 +1,29 @@ +package cn.iocoder.dashboard.framework.tracer.config; + +import cn.iocoder.dashboard.framework.tracer.annotation.BizTracingAop; +import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConditionalOnClass({BizTracingAop.class}) +@EnableConfigurationProperties(BizTracerProperties.class) +@ConditionalOnProperty(prefix = "yudao.tracer", value = "enable", matchIfMissing = true) +public class BizTracerAutoConfiguration { + + + @Bean + @ConditionalOnMissingBean + public BizTracerProperties bizTracerProperties() { + return new BizTracerProperties(); + } + + @Bean + public BizTracingAop enableBizTracingAop() { + return new BizTracingAop(); + } + +} diff --git a/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerProperties.java b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerProperties.java new file mode 100644 index 000000000..b831464e6 --- /dev/null +++ b/src/main/java/cn/iocoder/dashboard/framework/tracer/config/BizTracerProperties.java @@ -0,0 +1,9 @@ +package cn.iocoder.dashboard.framework.tracer.config; + +import lombok.Data; +import org.springframework.boot.context.properties.ConfigurationProperties; + +@ConfigurationProperties("yudao.tracer") +@Data +public class BizTracerProperties { +}