Spring Data Solr - 映射自定义存储库时的异常

时间:2013-05-26 08:23:17

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

我正在尝试使用自定义存储库进行分面搜索,如下所示:

存储库:

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

自定义界面:

public interface CustomSolrRepository { 

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

自定义impl:

@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的属性facet   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 $谓词(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个

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

1 个答案:

答案 0 :(得分:2)

问题在于我的存储库intrefaces的命名。修正:

存储库:POISearchRepository 自定义界面:POISearchRepositoryCustom 客户实施:POISearchRepositoryImpl

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