diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
index f84984c182..f73b900060 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/pom.xml
@@ -50,6 +50,7 @@
org.projectlombok
lombok
+ true
@@ -74,14 +75,17 @@
junit
junit
+ test
org.apache.curator
curator-test
+ test
com.h2database
h2
+ test
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
index 3dd0afe586..f50833f3b6 100644
--- a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/ElasticJobTracingConfiguration.java
@@ -25,6 +25,7 @@
import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
+import org.springframework.context.annotation.Configuration;
import org.springframework.lang.Nullable;
import javax.sql.DataSource;
@@ -32,42 +33,47 @@
/**
* ElasticJob tracing auto configuration.
*/
+@Configuration(proxyBeanMethods = false)
@EnableConfigurationProperties(TracingProperties.class)
public class ElasticJobTracingConfiguration {
- /**
- * Create a bean of tracing DataSource.
- *
- * @param tracingProperties tracing Properties
- * @return tracing DataSource
- */
- @Bean("tracingDataSource")
- public DataSource tracingDataSource(final TracingProperties tracingProperties) {
- DataSourceProperties dataSource = tracingProperties.getDataSource();
- if (dataSource == null) {
- return null;
+ @Configuration(proxyBeanMethods = false)
+ @ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = "RDB")
+ static class RDBTracingConfiguration {
+ /**
+ * Create a bean of tracing DataSource.
+ *
+ * @param tracingProperties tracing Properties
+ * @return tracing DataSource
+ */
+ @Bean("tracingDataSource")
+ public DataSource tracingDataSource(final TracingProperties tracingProperties) {
+ DataSourceProperties dataSource = tracingProperties.getDataSource();
+ if (dataSource == null) {
+ return null;
+ }
+ HikariDataSource tracingDataSource = new HikariDataSource();
+ tracingDataSource.setJdbcUrl(dataSource.getUrl());
+ BeanUtils.copyProperties(dataSource, tracingDataSource);
+ return tracingDataSource;
}
- HikariDataSource tracingDataSource = new HikariDataSource();
- tracingDataSource.setJdbcUrl(dataSource.getUrl());
- BeanUtils.copyProperties(dataSource, tracingDataSource);
- return tracingDataSource;
- }
- /**
- * Create a bean of tracing configuration.
- *
- * @param dataSource required by constructor
- * @param tracingDataSource tracing ataSource
- * @return a bean of tracing configuration
- */
- @Bean
- @ConditionalOnBean(DataSource.class)
- @ConditionalOnProperty(name = "elasticjob.tracing.type", havingValue = "RDB")
- public TracingConfiguration tracingConfiguration(final DataSource dataSource, @Nullable final DataSource tracingDataSource) {
- DataSource ds = tracingDataSource;
- if (ds == null) {
- ds = dataSource;
+ /**
+ * Create a bean of tracing configuration.
+ *
+ * @param dataSource required by constructor
+ * @param tracingDataSource tracing ataSource
+ * @return a bean of tracing configuration
+ */
+ @Bean
+ @ConditionalOnBean(DataSource.class)
+ public TracingConfiguration tracingConfiguration(final DataSource dataSource,
+ @Nullable final DataSource tracingDataSource) {
+ DataSource ds = tracingDataSource;
+ if (ds == null) {
+ ds = dataSource;
+ }
+ return new TracingConfiguration<>("RDB", ds);
}
- return new TracingConfiguration<>("RDB", ds);
}
}
diff --git a/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java
new file mode 100644
index 0000000000..5785969edb
--- /dev/null
+++ b/elasticjob-lite/elasticjob-lite-spring/elasticjob-lite-spring-boot-starter/src/test/java/org/apache/shardingsphere/elasticjob/lite/spring/boot/tracing/TracingConfigurationTest.java
@@ -0,0 +1,54 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.shardingsphere.elasticjob.lite.spring.boot.tracing;
+
+import org.apache.shardingsphere.elasticjob.lite.spring.boot.job.fixture.EmbedTestingServer;
+import org.apache.shardingsphere.elasticjob.tracing.api.TracingConfiguration;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.springframework.beans.factory.ObjectProvider;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.core.ResolvableType;
+import org.springframework.test.context.ActiveProfiles;
+import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests;
+
+import javax.sql.DataSource;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+
+@SpringBootTest
+@SpringBootApplication
+@ActiveProfiles("tracing")
+public class TracingConfigurationTest extends AbstractJUnit4SpringContextTests {
+
+ @BeforeClass
+ public static void init() {
+ EmbedTestingServer.start();
+ }
+
+ @Test
+ public void assertNotRDBConfiguration() {
+ assertNotNull(applicationContext);
+ assertFalse(applicationContext.containsBean("tracingDataSource"));
+ ObjectProvider