简体   繁体   English

使用spring-data重新定义存储库中的方法

[英]Redefine methods in repository with spring-data

I'm using spring-data-couchbase 2.1.2 , I want add methods to a single repository. 我正在使用spring-data-couchbase 2.1.2 ,我想将方法​​添加到单个存储库中。 In implementation class: 在实现类中:

public class MyRepositoryImpl implements MyRepositoryCustom { 

  @Autowired
  RepositoryOperationsMapping templateProvider; 
....
}

I added the RepositoryOperationsMapping but the object is not injected, I have the error below: 我添加了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

For spring configuration I used the spring.xml file, how add in xml file the RepositoryOperationsMapping reference? 对于spring配置,我使用了spring.xml文件,如何在xml文件中添加RepositoryOperationsMapping参考?

Thanks. 谢谢。 Bye. 再见

I solved the issue, below a snippet my spring.xml file 我在片段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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM