0

我正在使用spring-data-couchbase 2.1.2,我想将方法​​添加到单个存储库。在实现类中:

public class MyRepositoryImpl implements MyRepositoryCustom { 

  @Autowired
  RepositoryOperationsMapping templateProvider; 
....
}

我添加了RepositoryOperationsMapping但对象没有注入,我有以下错误:

[org.springframework.data.couchbase.repository.config.RepositoryOperationsMapping]: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: {@org.springframework.beans.factory.annotation.Autowired(required=true)}; nested exception is org.springframework.beans.factory.NoSuchBeanDefinitionException

对于我使用文件的spring配置spring.xml,如何在xml文件中添加RepositoryOperationsMapping参考?

谢谢。再见。

4

1 回答 1

0

我解决了这个问题,在我的spring.xml文件的一个片段下面

<couchbase:clusterInfo login="${cluster.username}" password="${cluster.password}"  id="clusterInfo" />

    <couchbase:bucket bucketName="${bucket.name}" bucketPassword="${bucket.password}" id="bucket"/>

    <!-- template is just using default parameters and references as well -->
     <couchbase:template translation-service-ref="myCustomTranslationService" />
     <bean id="myCustomTranslationService" 
  class="org.springframework.data.couchbase.core.convert.translation.JacksonTranslationService"/>



   <bean id="couchbaseTemplate" class="org.springframework.data.couchbase.core.CouchbaseTemplate">
        <constructor-arg ref="clusterInfo"/>
        <constructor-arg ref="bucket" />
        <constructor-arg ref="myCustomTranslationService" />
   </bean> 

   <bean id="repositoryOperationsMapping" class="org.springframework.data.couchbase.repository.config.RepositoryOperationsMapping"> 
     <constructor-arg ref="couchbaseTemplate"/> 
   </bean>
于 2016-07-15T19:03:40.520 回答