加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

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

发布时间:2020-12-15 01:46:22 所属栏目:大数据 来源:网络整理
导读:我试图弄清楚如何使Spring与Couchbase一起工作但由于某种原因我得到以下异常: Exception in thread "main" org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'bookRepo': Cannot resolve reference to bean 'couch

我试图弄清楚如何使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文件:

这是存储库:

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通它?有什么延迟?

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读