나는 봄이 카우치베이스 주식회사와 함께 작동하도록하지만 어떤 이유로 나는 다음과 같은 예외지고있어하는 방법을 알아 내려고 노력 해요 :"오류 이름으로 콩을 만드는"카우치베이스 주식회사 + 봄
이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
연결이입니다 괜찮지 만 콩을 만들 수없는 이유가 있습니다.
package com.jcg.examples.repo;
...
@Repository
public interface BookRepo extends CouchbaseRepository<Book, Long> {
@Query(value = "select * from JavaCodeGeeks")
public List<Book> getBooksByContainedWord(String containedString);
}
문서 :하십시오 여기
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;
}
}
그리고 내가 그것을 테스트하고 있습니다 방법은 다음과 같습니다
다음<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:couchbase="http://www.springframework.org/schema/data/couchbase"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/data/couchbase
http://www.springframework.org/schema/data/couchbase/spring-couchbase.xsd">
<couchbase:cluster>
<couchbase:node>127.0.0.1</couchbase:node>
</couchbase:cluster>
<!-- This is needed to probe the server for N1QL support -->
<!-- Can be either cluster credentials or a bucket credentials -->
<couchbase:clusterInfo login="login"
password="password" />
<beans:bean id="couchbaseEnv"
class="com.couchbase.client.java.env.DefaultCouchbaseEnvironment"
factory-method="create" />
<beans:bean id="myCustomTranslationService"
class="org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService" />
<couchbase:indexManager />
<couchbase:repositories base-package="com.jcg.examples.repo" />
<couchbase:template translation-service-ref="myCustomTranslationService" />
<couchbase:bucket bucketName="JavaCodeGeeks"
bucketPassword="password.1" />
</beans:beans>
저장소입니다 :
여기 내 spring-couchbase-integration.xml
파일입니다
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
그러나 나는 이것을 알아낼 수 없었다.
EDIT : 문제가 수정되어 by configuring the Docker container properly으로 수정되어 연결 문제가 해결되었습니다.
+1이 연결 문제처럼 보인다. 나는 couchbase 서버를 로컬로 설정하고 코드는 정상적으로 실행됩니다. 현재, 연결 시간이 초과되었습니다 :/ : 8092 문서를 추가하려고합니다. –
tomtomssi
8092는 뷰 (Spring Data Couchbase가 많이 사용하는 포트)입니다. 방화벽 문제가있을 수 있습니까? Couchbase SDK는 여러 포트, 특히 8091-8094 범위에서 클러스터 노드와 직접 대화를합니다. –
올바른 방향으로 지적했기 때문에 이것을 답으로 사용하겠습니다. 문제는 포트 및 도커 컨테이너 구성 방법과 관련되어있었습니다. 고맙습니다! – tomtomssi