简体   繁体   English

当 Spring 数据存储库扩展自定义存储库时出现 BeanCreationException

[英]BeanCreationException when Spring Data Repository extends Custom Repository

I have the following repository interface:我有以下存储库界面:

public interface FooRepository extends ReactiveMongoRepository<Foo, String>, CustomFooRepository {

}

And the following custom repository interface:以及以下自定义存储库接口:

public interface CustomFooRepository {

    Flux<Foo> findFooByFilters(FooSearchParams params);
}

With the following implementation:通过以下实现:

@RequiredArgsConstructor
public class DefaultCustomFooRepository implements CustomFooRepository {

    private final ReactiveFluentMongoOperations fluentMongoOps;

    @Override
    public Flux<Foo> findFooByFilter(FooSearchParams params) {
        return fluentMongoOps
                .query(Foo.class)
                // using the received params to create a dynamic query
                .all();
    }
}

But the Application Context fails with the following error:但是应用程序上下文失败并出现以下错误:

Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'fooRepository' defined in com.foo.fooservice.foo.FooRepository defined in @EnableReactiveMongoRepositories declared on MongoReactiveRepositoriesRegistrar.EnableReactiveMongoRepositoriesConfiguration: Invocation of init method failed; nested exception is org.springframework.data.mapping.PropertyReferenceException: No property filter found for type Foo!

I used to follow this exact practice when I needed to add custom methods to a Spring Data repository and I never encountered any problems, am I doing something wrong or has the behavior changed recently?当我需要将自定义方法添加到 Spring 数据存储库时,我曾经遵循这种确切的做法,但我从未遇到任何问题,是我做错了什么还是最近行为发生了变化?

Found the problem.发现了问题。

The name of my custom repository implementation was DefaultCustomFooRepository .我的自定义存储库实现的名称是DefaultCustomFooRepository

Renaming it to CustomFooRepositoryImpl fixed it.将其重命名为CustomFooRepositoryImpl修复了它。

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

相关问题 Spring Data Rest:为扩展Revision Repository的Repository公开新的端点 - Spring Data Rest: Expose new endpoints for Repository that extends Revision Repository 自定义MongoDB spring数据存储库 - Custom MongoDB spring data repository 自定义通用Spring数据存储库 - Custom generic spring data repository Spring Data Rest和Spring Data Envers:如何为扩展Revision Repository的Repository公开REST API - Spring Data Rest & Spring Data Envers: How to expose REST API for Repository that extends Revision Repository Spring JPA Data Repository无法为扩展CrudRepository的接口创建bean - Spring JPA Data Repository failed to create bean for interface that extends CrudRepository 创建自定义存储库时的spring-data-neo4j PropertyReferenceException - spring-data-neo4j PropertyReferenceException when creating custom repository @Inject自定义存储库中的存储库是错误的(Spring Data JPA) - Is it wrong to @Inject the repository in a custom repository (Spring Data JPA) Spring Data Couchbase自定义存储库方法 - Spring Data Couchbase custom repository method 自定义Spring Data Repository中的@Autowired依赖关系为null - @Autowired dependency in custom Spring Data Repository is null Spring Data REST:MongoDB存储库的自定义查询 - Spring Data REST : custom query for MongoDB repository
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM