【问题标题】:Spring Data Solr - Exception in mapping a custom repositorySpring Data Solr - 映射自定义存储库时出现异常
【发布时间】:2013-05-21 09:09:27
【问题描述】:

我正在尝试将分面搜索与自定义存储库一起使用,如下所示:

存储库:

public interface POISearchRepository extends CustomSolrRepository, SolrCrudRepository<POISearch, String>

自定义界面:

public interface CustomSolrRepository { 

     FacetPage<POISearch> facetSearch(String location, String categories, String duration, Pageable page) throws Exception; 
}

自定义实现:

@Repository
public class POISearchImpl implements CustomSolrRepository {

@Resource
private SolrTemplate solrTemplate;

@Override
public FacetPage<POISearch> facetSearch(String location, String categories, String duration, Pageable page) throws Exception {

......
}

不幸的是,我不断收到以下异常:

原因: org.springframework.data.mapping.PropertyReferenceException:否 找到类型 com.example.domain.POISearch 的属性构面,位于 org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:327) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) 在 org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271) 在 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) 在 org.springframework.data.repository.query.parser.Part.(Part.java:72) 在 org.springframework.data.repository.query.parser.PartTree$OrPart.(PartTree.java:180) 在 org.springframework.data.repository.query.parser.PartTree$Predicate.buildTree(PartTree.java:260) 在 org.springframework.data.repository.query.parser.PartTree$Predicate.(PartTree.java:240) 在 org.springframework.data.repository.query.parser.PartTree.(PartTree.java:68) 在 org.springframework.data.solr.repository.query.PartTreeSolrQuery.(PartTreeSolrQuery.java:36) 在 org.springframework.data.solr.repository.support.SolrRepositoryFactory$SolrQueryLookupStrategy.resolveQuery(SolrRepositoryFactory.java:101) 在 org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.(RepositoryFactorySupport.java:279) 在 org.springframework.data.repository.core.support.RepositoryFactorySupport.getRepository(RepositoryFactorySupport.java:147) 在 org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:153) 在 org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43) 在 org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java:142) ... 57 更多

似乎存储库试图解析自定义方法并导致异常(更改方法名称表明)

【问题讨论】:

    标签: spring solr spring-data facets spring-data-solr


    【解决方案1】:

    问题在于我的存储库接口的命名。修复:

    存储库:POISearchRepository 自定义接口:POISearchRepositoryCustom 客户实现:POISearchRepositoryImpl

    我最初的命名不符合 Spring Data 规范

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-03-26
      • 2018-10-06
      • 2017-09-19
      • 2017-03-22
      • 2017-02-09
      • 2016-08-29
      • 1970-01-01
      相关资源
      最近更新 更多