diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosReactiveRepositoriesAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosReactiveRepositoriesAutoConfiguration.java index 9530b250f1129..57bda8d17cd22 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosReactiveRepositoriesAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosReactiveRepositoriesAutoConfiguration.java @@ -3,9 +3,12 @@ package com.azure.spring.cloud.autoconfigure.data.cosmos; +import com.azure.spring.data.cosmos.core.ReactiveCosmosTemplate; import com.azure.spring.data.cosmos.repository.ReactiveCosmosRepository; import com.azure.spring.data.cosmos.repository.config.ReactiveCosmosRepositoryConfigurationExtension; import com.azure.spring.data.cosmos.repository.support.ReactiveCosmosRepositoryFactoryBean; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -19,7 +22,9 @@ @ConditionalOnClass({ ReactiveCosmosRepository.class }) @ConditionalOnMissingBean({ ReactiveCosmosRepositoryFactoryBean.class, ReactiveCosmosRepositoryConfigurationExtension.class }) -@ConditionalOnProperty(prefix = "azure.cosmos.repositories", +@AutoConfigureAfter(CosmosDataAutoConfiguration.class) +@ConditionalOnBean(ReactiveCosmosTemplate.class) +@ConditionalOnProperty(prefix = "spring.cloud.azure.cosmos.repositories", name = "enabled", havingValue = "true", matchIfMissing = true) diff --git a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosRepositoriesAutoConfiguration.java b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosRepositoriesAutoConfiguration.java index 6c218e291ac3d..feb442d2ccc77 100644 --- a/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosRepositoriesAutoConfiguration.java +++ b/sdk/spring/spring-cloud-azure-autoconfigure/src/main/java/com/azure/spring/cloud/autoconfigure/data/cosmos/CosmosRepositoriesAutoConfiguration.java @@ -3,9 +3,12 @@ package com.azure.spring.cloud.autoconfigure.data.cosmos; +import com.azure.spring.data.cosmos.core.CosmosTemplate; import com.azure.spring.data.cosmos.repository.CosmosRepository; import com.azure.spring.data.cosmos.repository.config.CosmosRepositoryConfigurationExtension; import com.azure.spring.data.cosmos.repository.support.CosmosRepositoryFactoryBean; +import org.springframework.boot.autoconfigure.AutoConfigureAfter; +import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnClass; import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; @@ -19,7 +22,9 @@ @ConditionalOnClass({ CosmosRepository.class }) @ConditionalOnMissingBean({ CosmosRepositoryFactoryBean.class, CosmosRepositoryConfigurationExtension.class }) -@ConditionalOnProperty(prefix = "azure.cosmos.repositories", +@AutoConfigureAfter(CosmosDataAutoConfiguration.class) +@ConditionalOnBean(CosmosTemplate.class) +@ConditionalOnProperty(prefix = "spring.cloud.azure.cosmos.repositories", name = "enabled", havingValue = "true", matchIfMissing = true)