Made the changes, on application startup it opens two buckets.
Can see below have mapped the entity class in base mapping .This repository should connect to second bucket.
But when I try to fetch data still its always connecting to first bucket and gives data not found exception.
Here’s my configuration class ( below code is working after making suggested changes)
/** Standard connection string and cluster connection details code goes here**/
@Configuration
@EnableReactiveCouchbaseRepositories(basePackages = "**.repository")
public class CouchbaseConfig extends AbstractCouchbaseConfiguration {
public CouchbaseClientFactory couchbaseClientFactoryForContent() {
return new SimpleCouchbaseClientFactory(getConnectionString(), authenticator(),
env.getProperty("spring.couchbase.bucket.content.name"));
}
public ReactiveCouchbaseTemplate myReactiveCouchbaseTemplate(CouchbaseClientFactory couchbaseClientFactory,
MappingCouchbaseConverter mappingCouchbaseConverter) {
return new ReactiveCouchbaseTemplate(couchbaseClientFactory, mappingCouchbaseConverter);
}
@Override
@Bean(name = BeanNames.REACTIVE_COUCHBASE_OPERATIONS_MAPPING)
public ReactiveRepositoryOperationsMapping reactiveCouchbaseRepositoryOperationsMapping(
ReactiveCouchbaseTemplate reactiveCouchbaseTemplate) {
// create a base mapping that associates all repositories to the default
// template
ReactiveRepositoryOperationsMapping baseMapping = new ReactiveRepositoryOperationsMapping(
reactiveCouchbaseTemplate(couchbaseClientFactory(couchbaseCluster(couchbaseClusterEnvironment())),
new MappingCouchbaseConverter()));
// let the user tune it
configureReactiveRepositoryOperationsMapping(baseMapping);
return baseMapping;
}
@Override
public void configureReactiveRepositoryOperationsMapping(ReactiveRepositoryOperationsMapping baseMapping) {
try {
baseMapping.mapEntity(Model.class,
myReactiveCouchbaseTemplate(couchbaseClientFactoryForContent(), new MappingCouchbaseConverter()));
} catch (Exception e) {
// custom Exception handling
}
}
}