1

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

存储库:

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:在 org.springframework.data.mapping.PropertyPath.(PropertyPath.java:75) 在 org.springframework.data 中找不到类型 com.example.domain.POISearch 的属性方面.mapping.PropertyPath.create(PropertyPath.java:327) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:353) at org.springframework.data.mapping.PropertyPath.create(PropertyPath.java:307 ) 在 org.springframework.data.repository.query 的 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:245) 的 org.springframework.data.mapping.PropertyPath.from(PropertyPath.java:271)。 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) at org.springframework.data.repository.query.parser.PartTree$Predicate.(PartTree.java:240) at org.springframework.data.repository.query.parser.PartTree .(PartTree.java:68) at org.springframework.data.solr.repository.query.PartTreeSolrQuery.(PartTreeSolrQuery.java:36) at 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) at org.springframework.data.repository.core.support.RepositoryFactoryBeanSupport.getObject(RepositoryFactoryBeanSupport.java:43) at org.springframework.beans.factory.support.FactoryBeanRegistrySupport.doGetObjectFromFactoryBean(FactoryBeanRegistrySupport.java: 142) ... 57 更多

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

4

1 回答 1

2

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

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

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

于 2013-05-26T11:43:22.347 回答