diff --git a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/ElasticJobTracingConfiguration.java b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/ElasticJobTracingConfiguration.java index 6ed0edfba..262f117ba 100644 --- a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/ElasticJobTracingConfiguration.java +++ b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/ElasticJobTracingConfiguration.java @@ -21,7 +21,6 @@ import org.apache.shardingsphere.elasticjob.kernel.tracing.config.TracingConfiguration; import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Qualifier; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -68,9 +67,11 @@ public DataSource tracingDataSource(final TracingProperties tracingProperties) { * @return a bean of tracing configuration */ @Bean - @ConditionalOnBean(DataSource.class) - public TracingConfiguration tracingConfiguration(@Qualifier("dataSource") final DataSource dataSource, + public TracingConfiguration tracingConfiguration(@Qualifier("dataSource") @Nullable final DataSource dataSource, @Qualifier("tracingDataSource") @Nullable final DataSource tracingDataSource) { + if (dataSource == null && tracingDataSource == null) { + throw new IllegalArgumentException("Neither dataSource nor tracingDataSource bean is required"); + } return new TracingConfiguration<>("RDB", null == tracingDataSource ? dataSource : tracingDataSource); } } diff --git a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/TracingProperties.java b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/TracingProperties.java index d34fc18cb..479dae86c 100644 --- a/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/TracingProperties.java +++ b/spring/boot-starter/src/main/java/org/apache/shardingsphere/elasticjob/spring/boot/tracing/TracingProperties.java @@ -21,6 +21,7 @@ import lombok.Setter; import org.springframework.boot.autoconfigure.jdbc.DataSourceProperties; import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.boot.context.properties.NestedConfigurationProperty; import java.util.HashSet; import java.util.Set; @@ -32,6 +33,7 @@ public class TracingProperties { private String type; + @NestedConfigurationProperty private DataSourceProperties dataSource; private Set includeJobNames = new HashSet<>();