【发布时间】:2023-03-14 20:38:01
【问题描述】:
我的数据人员给了我http://127.0.0.1:8091/pools url 以连接到我们的Couchbase 服务器,我被告知pools 后缀是集群中所有节点的地址。
我使用 Spring 4.2.0.RELEASE 和 spring-data-couchbase 2.0.0.M1 对抗 Couchbase 2.5.1 企业版(build-1083)
现在,如果我将上面的 url 按原样添加到 getBootstrapHosts 列表中:
@Override
protected List<String> getBootstrapHosts() {
return Collections.singletonList(couchbaseProperties.getHost());
}
8091/pools 值出现数字格式异常。
但是当使用http://127.0.0.1:8091 url 时,我得到一个无效密码异常。
我认为第一个 url 将被使用,但不是我所采用的方式。
在 AbstractCouchbaseConfiguration 类中可能有一个我应该重写的方法,但是查看源代码并没有真正启发我。
这里是 Couchbase 配置类。
@Configuration
@EnableCouchbaseRepositories(basePackages = { "com.thalasoft.data.couchbase.repository" })
@ComponentScan(nameGenerator = PackageBeanNameGenerator.class, basePackages = { "com.thalasoft.data.couchbase.config" })
@EnableTransactionManagement
public class CouchbaseConfiguration extends AbstractCouchbaseConfiguration {
private static Logger logger = LoggerFactory.getLogger(CouchbaseConfiguration.class);
@Autowired
private CouchbaseProperties couchbaseProperties;
@Override
protected List<String> getBootstrapHosts() {
return Collections.singletonList(couchbaseProperties.getHost());
}
@Override
protected String getBucketName() {
return couchbaseProperties.getBucketName();
}
@Override
protected String getBucketPassword() {
return couchbaseProperties.getBucketPassword();
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
return new PropertySourcesPlaceholderConfigurer();
}
@Bean
public LocalValidatorFactoryBean validator() {
return new LocalValidatorFactoryBean();
}
@Bean
public ValidatingCouchbaseEventListener validationEventListener() {
return new ValidatingCouchbaseEventListener(validator());
}
}
【问题讨论】:
-
pools 后缀是节点将服务于“集群图”的端点,可用于提取集群中所有节点的列表。但是,2.x SDK 将设法自行获取该集群图。它只需要一个或最好是两个节点的 ip 或主机名进行初始联系(引导)
标签: couchbase spring-data-couchbase