I'm looking for a way to use Spring Data Couchbase to connect to two separate Couchbase clusters. Looking at the documentation and the implementation, it is not clear as how to do this and my concern is that there will be bean name conflicts if have two configurations that extend AbstractCouchbaseConfiguration
. The only thing that looks close is to use the RepositoryOperationsMapping
to specify different templates for different repositories. This however doesn't suit my needs as each of the Couchbase configurations will not be aware of the other. The only means i see of doing this now is to either not use AbstractCouchbaseConfiguration
and setup my own beans or to override all the beans in AbstractCouchbaseConfiguration
and provide new bean names. In each case, i would override the couchbase template bean name in the @EnableCouchbaseRepositories
annotation. However, i'm not sure if this is going to work or if there is a better option.
Is this possible and if so, what is the best route for me to take?
Thank you
Could you elaborate on the use case that warranted the creation and connection to two separate clusters?
The best route here is still probably to define new Cluster
, Bucket
and CouchbaseTemplate
beans, with custom names, in your existing AbstractCouchbaseConfiguration
, and then use the configureRepositoryOperationsMapping()
method in the conf. Basically like described in the doc about multiple buckets, but adding a second Cluster
bean to the mix.
来源:https://stackoverflow.com/questions/36317444/use-spring-data-couchbase-to-connect-to-different-couchbase-clusters