Search code examples
couchbasespring-data-couchbase

Spring Data Couchbase - connect to several nodes


Java Couchbase client allows connecting to several nodes in a cluster (in case that one of them is not available)

Is is possible in Spring Data Couchbase?

I'm using Couchbase 2.1 and XML configuration for Spring


Solution

  • Yes, you can configure spring-data this way. When you configure the CouchbaseClient using the CouchbaseFactoryBean, it accepts a comma-delimited list of hosts. Here is an example of configuring the CouchbaseClient bean:

    <couchbase:couchbase  bucket="myBucket" password="" host="host1,host2,host3"/>
    

    This is assuming you are using the 1.4.x couchbase-client.jar dependency, which as long as you are using spring-data 1.1.5, you are fine. You didn't specify your spring-data dependencies, but more than likely you should be good here.