我的数据人员给了我http://127.0.0.1:8091/pools
连接到我们的 Couchbase 服务器的 url,我被告知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());
}
}