添加页面支持导致错误 - 可分页可分页 - spring-data-mongodb

时间:2013-04-11 10:37:21

标签: mongodb spring-data-mongodb

我有这样的存储库:

public interface IDomainRepository extends MongoRepository<Domain, String>{
}

我添加这样的分页支持后:

public interface IDomainRepository extends MongoRepository<Domain, String>{    
    Page<Domain> getDomains(String projectId, Pageable pageable);
}

我有错误:

Caused by: java.lang.IllegalArgumentException: No property get found for type class org.krams.tutorial.domain.nosql.Domain
at org.springframework.data.repository.query.parser.Property.<init>(Property.java:73)
at org.springframework.data.repository.query.parser.Property.<init> ...

我的pom.xml中的版本是:

<!-- Versions -->
    <properties>
        <spring.version>3.2.1.RELEASE</spring.version>
        <spring.data.jpa.version>1.3.0.RELEASE</spring.data.jpa.version>
        <spring.data.mongo.version>1.2.0.BUILD-SNAPSHOT</spring.data.mongo.version>
        <spring.amqp.version>1.0.0.RELEASE</spring.amqp.version>
        <slf4j-version>1.6.1</slf4j-version>
        <org.cloudfoundry-version>0.8.0</org.cloudfoundry-version>
        <jackson-mapper>1.9.10</jackson-mapper>
    </properties>

有什么问题?

1 个答案:

答案 0 :(得分:0)

好的,明白了! 错误的原因是:
如果你想在MongoRepository中使用Pageable,
域对象需要有成员域,因此您可以添加如

之类的功能
public Page<Domain> findByDomains(String domains, Pageable pageable);