微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

java – “创建名为bean的错误”Couchbase Spring

我试图弄清楚如何使Spring与Couchbase一起工作但由于某种原因我得到以下异常:

Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookRepo': Cannot resolve reference to bean 'couchbaseTemplate' while setting bean property 'couchbaSEOperations'; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseTemplate': Cannot resolve reference to bean 'couchbaseBucket' while setting constructor argument; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'couchbaseBucket': Invocation of init method Failed; nested exception is java.lang.RuntimeException: java.util.concurrent.TimeoutException

连接很好,但由于某种原因无法创建bean.

这是我的spring-couchbase-integration.xml文件

spring-beans-4.1.xsd
    http://www.springframework.org/schema/data/couchbase
    http://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd">

    

这是存储库:

package com.jcg.examples.repo;

...

@Repository
public interface BookRepo extends CouchbaseRepository

文件

package com.jcg.examples.entity;

...

@Document(expiry = 0)
public class Book {

    @Id
    private long bookId;

    public long getBookId() {
        return bookId;
    }

    public void setBookId(long bookId) {
            this.bookId = bookId;
    }

}

这是我如何测试它:

package com.jcg.examples;

...

public class ApplicationTest {

    public static void main(String[] args) {
        ClasspathXmlApplicationContext context = new ClasspathXmlApplicationContext(new ClassPathResource("spring-couchbase-integration.xml").getPath());
    }
}

这个例子取自this website.我已经设法解决了连接问题,因为我实际上并没有使用localhost,但是我无法弄清楚这一点.

编辑:问题已修复by configuring the Docker container properly因此修复了连接问题.

最佳答案
该消息表明SDK无法足够快地连接到群集.认超时为5秒.

Couchbase Server是否已启动并在localhost上运行?如果您在实际配置中使用其他IP,客户端机器是否可以ping通它?有什么延迟?

您可以尝试设置更高的超时(以毫秒为单位):

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐